mn8 Language Reference | Index    

Mbox

SUMMARY: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: NO ATTRIBUTES  NO ELEMENTS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

This concept helps you to manage your mailbox. You can use it like a handler or a concept.

Usage

This example will show how you can use the mailbox concept like a concept.

    $expr = Simplex.create("*nextra*")

    #creating the mailbox concept, the URL shows your mailbox file
    #can use similarly the file:// protocoll

    $mb = Mbox.create("mbox://var/mail/spool/atech")

    #if you have a RFC822 compatible message stored in $msg
    #you can add to your mailbox

    $mb.addMessage($msg)

    #checking my mails
    print "My mails in mbox: " + $mb.check

    #let show the message ids (all)
    print "IDs:   " + $mb.getID

    #let show the message ids matching expression $expr
    print "Filtered IDs:   " + $mb.getID($expr)

    #my first message id
    $id = $mb.getID/1

    #I'm curious, I want to see my first message header
    $heads = $mb.getHeader($id)
    print $heads/1.toXML

    #all the headers and headers matching my $expr expression
    $heads = $mb.getHeader("")
    $heads = $mb.getHeader($expr)

    #my first message
    $mails =  $mb.getMessage($id)
    print $mails/1.toXML

    #all the messages and messages matching my $expr expression    
    $mails = $mb.getMessage("")
    $mails = $mb.getMessage($expr)

    #my first message is ugly, I will delete it
    $mb.delete($id)   

    #all my messages are ugly :)
    #take care all messages will be deleted!
    $mb.DeleteAll

    #I want to know what mailbox I use?
    print "My mailbox is: " + $mb.getResourceURI

    #I want to know where my message coming from?
    print "The Message mailbox is: " + $mb.getMessage($id)/1.getResourceURI

    #the message original form (RFC822 message source)
    print "Orig Message: " + $mb.getMessage($id)/1.toTXT

This example will show how you can use the mailbox concept like a handler. Can use in URL an URL query (..?cmd=getHeader&requests=5) or similarly an options argument after from ("cmd"="getHeader", "requests"=5)


    #if you have a RFC822 compatible message stored in $msg
    #you can add to your mailbox

    $msg to "mbox://var/spool/mail/atech"


    #checking my mails in two ways, of course use only one
    $mb from "mbox://var/spool/mail/atech?cmd=check"
    $mb from "mbox://var/spool/mail/atech" options "cmd"="check"

    print "Mails in mbox: " + $mb
    #let show the message ids (all)
    $ids from "mbox://var/spool//mail/atech" options "cmd"="getID"
    print $ids

    #get the message ids matching expression $expr    
    $mb from "mbox://var/spool//mail/atech" options "cmd"="getID", "filter"=$expr

    #get the message headers
    $mb from "mbox://var/spool//mail/atech" options "cmd"="getHeaders", "id"=""

    #get the message header for specified id
    $ids from "mbox://var/spool//mail/atech" options "cmd"="getID"
    $heads from "mbox://var/spool//mail/atech" options "cmd"="getHeaders", "id"=$ids/1
    print $heads/1.toXML

    #get the first five messages
    $msgs from "mbox://var/spool//mail/atech" options "cmd"="getMessage","requests"=5

    #delete the specified message 
    $heads from "mbox://var/spool//mail/atech" options "cmd"="delete", "id"=$ids/1

    #delete all my messages
    $heads from "mbox://var/spool//mail/atech" options "cmd"="deleteAll"

Version: 0.1
Authors:Antal Attila ()
Location:
Inherits: Concept

Constructor List

create (String )
top

Method List

static LogicalacceptsURI (String )
LogicalopenConnection
addMessage (String )
Integercheck
delete (String )
deleteAll
SeriesgetHeader (String )
SeriesgetHeader (Expression )
SeriesgetID
SeriesgetID (Expression )
SeriesgetMessage (Expression )
SeriesgetMessage (String )
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI

Detailed Constructor Info

create (String )
Parameters:
:URL string
Exceptions:
badURLException :
(Error)
If the URL to the mBox isn't valid.

Creating the concept with a named URL string

top

Detailed Method Info

static acceptsURI (String )
Parameters:
:URL string
Returns: Logical

Looking if your URL protocol is accepted.

  print Mbox.acceptsURI("mbox://home/guest/nsmail/Inbox")
  -- the result is --
  true
  

top
openConnection
Returns: Logical
Exceptions:
connectionException :
(Error)
If unable to connect to specified XML database.

Opens the mbox connection.

top
addMessage (String )
Parameters:
:Mail message
Returns:
Exceptions:
mboxOperationException :
(Error)
If unable to add message to the mailbox

Adds (appends) your message to mailbox, if the mailbox isn't exists it will be created.

  $inbox = Mbox.create("mbox://home/guest/nsmail/Inbox")
  $friends = Mbox.create("mbox://home/guest/nsmail/Friends")
  print $friends.check
  $msg = $inbox.getMessage(Simplex.create("*Jim*"))
  while ($msg@hasNext) do [
    $friends.addMessage($msg.next)
  ]
  print $friends.check
  -- the result is --
  3
  8
  

top
check
Returns: Integer
Exceptions:
mboxOperationException :
(Error)
If unable to check the mailbox

Checking the mailbox and returns the number of messages

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.check
  -- the result is --
  12
  

top
delete (String )
Parameters:
:Message id
Returns:
Exceptions:
mboxOperationException :
(Error)
If unable to delete the message

Delete message with named id.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.getID
  $mbx.delete($mbx.getID(Simplex.create("*outblaze*"))/1/)
  print $mbx.getID
  -- the result is --
  <200204090516.g395G5207064@ns.compila2.net>
  <200202072116.g17LGMP08201@www.avidgamers.com>
  <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  <20010921161121.03483.03184945@newman-m02.aol.com>

  <200204090516.g395G5207064@ns.compila2.net>
  <200202072116.g17LGMP08201@www.avidgamers.com>
  <20010921161121.03483.03184945@newman-m02.aol.com>
  

top
deleteAll
Returns:
Exceptions:
mboxOperationException :
(Error)
If unable to delete the all messages

Deletes all messages.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  $mbx.check
  $mbx.deleteAll
  $mbx.check
  -- the result is --
  12
  0
  

top
getHeader (String )
Parameters:
:Message id
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the message headers

Gets the named message header, if the parameter is empty will returns all the messages.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  $msgID = $mbx.getID(Simplex.create("*outblaze*"))
  print $mbx.getHeader($msgID)
  -- the result is --
  emx:Message
        xmlns:rfc822: URN:ietf:params:rfc822:   xmlns:emx: URN:ietf:params:email-xml:
  rfc822:subject
        TEST
  rfc822:message-id
        <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  emx:part
  rfc822:content-type
        charset: US-ASCII
        TEXT/PLAIN
  

top
getHeader (Expression )
Parameters:
:Expression concept
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the message headers

Gets the message headers matching to the expression given as parameter.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.getHeader(Simplex.create("*outblaze*"))
  -- the result is --
  emx:Message
        xmlns:rfc822: URN:ietf:params:rfc822:   xmlns:emx: URN:ietf:params:email-xml:
  rfc822:subject
        TEST
  rfc822:message-id
        <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  emx:part
  rfc822:content-type
        charset: US-ASCII
        TEXT/PLAIN
  

top
getID
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the message ids

Gets the messages id.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.getID
  -- the result is --
  <200204090516.g395G5207064@ns.compila2.net>
  <200202072116.g17LGMP08201@www.avidgamers.com>
  <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  <20010921161121.03483.03184945@newman-m02.aol.com>
  

top
getID (Expression )
Parameters:
:Expression concept
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the message ids

Gets the ids matching to the expression given as parameter.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.getID(Simplex.create("*outblaze*"))
  -- the result is --
  <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  

top
getMessage (Expression )
Parameters:
:Expression concept
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the messages

Gets the messages matching to the expression given as parameter.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  print $mbx.getMessage(Simplex.create("*Hi!*"))
  -- the result is --
  emx:Message
        xmlns:rfc822: URN:ietf:params:rfc822:   xmlns:emx: URN:ietf:params:email-xml:
  rfc822:subject
        TEST
  rfc822:message-id
        <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  emx:part
  rfc822:content-type
        charset: US-ASCII
        TEXT/PLAIN
  emx:BodyPart
        Hi! This is a test mail.
  

top
getMessage (String )
Parameters:
:Message id
Returns: Series
Exceptions:
mboxOperationException :
(Error)
If unable to get the messages

Gets the named messages, if the parameter is empty will returns all the messages.

  $mbx = Mbox.create("mbox://home/guest/nsmail/Inbox")
  $msgID = $mbx.getID(Simplex.create("*outblaze*"))
  print $mbx.getMessage($msgID)
  -- the result is --
  emx:Message
        xmlns:rfc822: URN:ietf:params:rfc822:   xmlns:emx: URN:ietf:params:email-xml:
  rfc822:subject
        TEST
  rfc822:message-id
        <20011217100619.17459.qmail@mta4-3.us4.outblaze.com>
  emx:part
  rfc822:content-type
        charset: US-ASCII
        TEXT/PLAIN
  emx:BodyPart
        Hi! This is a test mail.
  

top