Public Attributes | |
AttachDir | |
When receiving messages using POP3, the directory where attached files will be stored. More... | |
Connected | |
More... | |
Debug | |
More... | |
StoreAttachToFile | |
We always store attachments as a part in the message. More... | |
StoreInlineToFile | |
We always store attachments as a part in the message. More... | |
Private Member Functions | |
_.Library.Status | OnClose () |
Additional Inherited Members | |
![]() | |
CAPTION = None | |
Optional name used by the Form Wizard for a class when generating forms. More... | |
JAVATYPE = None | |
The Java type to be used when exported. | |
PROPERTYVALIDATION = None | |
This parameter controls the default validation behavior for the object. More... | |
For information on using the API provided by this class, see Sending and Receiving Email.
Abstract Class that <class>Net.POP3</class> implements.
Methods are <METHOD>Connect,</Method>,<METHOD>GetMailBoxStatus</METHOD>, <METHOD>GetSizeOfMessages</METHOD>,<METHOD>GetMessageUIDArray</METHOD>, <METHOD>FetchMessage</METHOD>,<METHOD>DeleteMessage</METHOD>, <METHOD>RollbackDeletes</METHOD>,<METHOD>QuitAndCommit</METHOD>, <METHOD>QuitAndRollback</METHOD>,<METHOD>Ping</METHOD>.
Important after <METHOD>Connect</METHOD> is called, you must call before your session ends either <METHOD>QuitAndCommit</METHOD> or <METHOD>QuitAndRollback</METHOD>.
Each of the methods of this class returns a value of type Status indicating success or failure.
The charset used for each text mail message part is returned in the <property>Charset</property> property of the <class>Net.MailMessagePart</class> class. The data is automatically translated to the current cache locale's default character set when reading from the TextData text stream.
The following shows an example of getting messages:
#include occOptions #include occStatus
; display mail but don't delete from mailbox testmail6 ; new mailserver,status,err,mailMsg set mailserver=##class(Net.POP3).New() set mailserver.AttachDir="d:\attach\" ; need terminating \ set mailserver.StoreAttachToFile=1 write !,"Calling Connect" set status=mailserver.Connect("moon.kinich.com","testjsl","jsltest") if $$$ISERR(status) do DecomposeStatus^apiOBJ(status,.err) write !,err(err),! quit write !,"Calling Fetch to retrieve the oldest message on the server." set status=mailserver.Fetch(1,.mailMsg,0) if $$$ISERR(status) do DecomposeStatus^apiOBJ(status,.err) write !,err(err),! quit write !,"from="_mailMsg.From write !,"to="_mailMsg.Headers.GetAt("to") write !,"date="_mailMsg.Date write !,"subject="_mailMsg.Subject write !,"messagesize="_mailMsg.MessageSize do DumpMessage(mailMsg) quit
DumpMessage(msg) new i,index,value,len if msg.IsMultiPart { for i=1:1:msg.Parts.Count() write !,"Dumping part "_i do DumpMessage(msg.Parts.GetAt(i)) quit }
set index="" for set value=msg.Headers.GetNext(.index) quit:index="" write !,"Headers("_index_")="_value if msg.IsBinary { write !,"msg is binary, filename="_msg.FileName_" filename="_msg.GetAttribute("content-disposition","filename") } else { write !,"Dumping text msg Filename="_msg.FileName_" filename="_msg.GetAttribute("content-disposition","filename"),! set stream=msg.TextData do stream.Rewind() set len=32763 while 'stream.AtEnd { write stream.Read(.len) } } quit
|
private |
Protect against terminating without doing a quit
Reimplemented from RegisteredObject.
Reimplemented in POP3.
_.Library.Status Connect | ( | _.Library.String | PopServer, |
_.Library.String | UserName, | ||
_.Library.String | Password | ||
) |
Use to logon to your mail server using the
username and password that are the parameters to this routine.
_.Library.Status DeleteMessage | ( | _.Library.Integer | MessageNumber | ) |
This method deletes a single message. MessageNumber must be a
valid message number and the message must not be currently marked for deletion.
Reimplemented in POP3.
_.Library.Status Fetch | ( | _.Library.Integer | MessageNumber, |
_.Net.MailMessage | Msg, | ||
_.Library.Boolean | Delete, | ||
_.Library.BinaryStream | messageStream | ||
) |
This method retrieves a single message. MessageNumber must be a
valid message number and the message must not be currently marked for deletion.
Msg is a MailMessage (possibly multipart) and a return parameter.
The fetched mail message is returned in this parameter
If Delete is 1, the message is deleted. If 0, it is not deleted.
If messageStream is specified, then the original message is written to this binary stream. messageStream needs to be a binary stream since mail messages may include binary data and multiple charsets.
Reimplemented in POP3.
_.Library.Status FetchFromStream | ( | _.Library.BinaryStream | messageStream, |
_.Net.MailMessage | Msg | ||
) |
This method retrieves a single eml format message from a binary stream.
messageStream must be a binary stream containing the message.
Msg is a MailMessage (possibly multipart) and a return parameter.
The fetched mail message is returned in this parameter
Reimplemented in POP3.
_.Library.Status FetchMessage | ( | _.Library.Integer | MessageNumber, |
_.Library.String | From, | ||
_.Library.String | To, | ||
_.Library.String | Date, | ||
_.Library.String | Subject, | ||
_.Library.Integer | MessageSize, | ||
_.Library.ArrayOfDataTypes | MsgHeaders, | ||
_.Net.MailMessage | Msg, | ||
_.Library.Boolean | Delete | ||
) |
This method retrieves a single message. MessageNumber must be a
valid message number and the message must not be currently marked for deletion.
Msg is a MailMessage (possibly multipart) and a return parameter.
The fetched mail message is returned in this parameter
If Delete is 1, the message is deleted. If 0, it is not deleted.
FetchMessage also returns selected headers in additional by reference parameters as well as the array of all headers.
Reimplemented in POP3.
_.Library.Status FetchMessageInfo | ( | _.Library.Integer | MessageNumber, |
_.Library.Integer | Lines, | ||
_.Library.String | From, | ||
_.Library.String | To, | ||
_.Library.String | Date, | ||
_.Library.String | Subject, | ||
_.Library.Integer | MessageSize, | ||
_.Library.ArrayOfDataTypes | MsgHeaders, | ||
_.Library.String | MessageText | ||
) |
This method retrieves a single message. MessageNumber must be a
valid message number and the message must not be currently marked for deletion.
An upper bound is put on number of lines of message text retrieved by Lines.
The text of the retrieved message is returned in the MessageText argument as a String.
FetchMessageInfo is typically used to get From, Date, and other header information without actually getting the message text. This allows one to filter out messages from parties one wishes to exclude or to zero in on messages one particularly wants. Since getting message text is something that can happen over a slow modem, this is a desirable feature.
Reimplemented in POP3.
_.Library.Status GetMailBoxStatus | ( | _.Library.Integer | NumberOfMessages, |
_.Library.Integer | NumberOfBytes | ||
) |
Get information about your mail box, the number of bytes it
contains, and the number of messages;
Reimplemented in POP3.
_.Library.Status GetMessageUID | ( | _.Library.Integer | MessageNumber, |
_.Library.String | UniqueID | ||
) |
For the message number singled out by MessageNumber, this
function returns the corresponding unique id. The message number must not correspond to a non-existent message or a message already marked for deletion or an error message is returned.
The unique message identifier is at most 70 characters long and each character is ASCII and printable (0x21 to 0x7E).
Each identifier is unique within the mailbox and is persistent. If a given message has a particular unique identifier in one session, it must have the same unique ID in all sessions. Once used, a given UID can never be reused even if the corresponding message is deleted.
If a specified message (corresponding to MessageNumber) does not exist or is marked for deletion, the function returns an error Status.
This command is used to implement a poor mans server-based message store. Basically, a client does not automatically delete messages, after getting messages, then at the start of each session, it calls GetMessageUIDs to obtain a list of all messages currently on the server. Any UIDs not currently known by the client are retrieved. That of course requires the client to keep track of the UIDs for all retrieved messages.
Reimplemented in POP3.
_.Library.Status GetMessageUIDArray | ( | _.Library.String | MessageNumber, |
_.Library.ArrayOfDataTypes | ListOfUniqueIDs | ||
) |
If you pass in an empty string "", an array with an element for
each of the messages not marked for deletion is returned.
Each element of the array has the message number as its index and the unique message identifier (UID) as its value..
If you pass in a message number, a one element array is returned. The element has the message number as its index and unique message identifier (UID) as its value. An error status is returned if a message with this message number does not exist or has been marked for deletion.
The unique message identifier is at most 70 characters long and each character is ASCII and printable (0x21 to 0x7E).
Each identifier is unique within the mailbox and is persistent. If a given message has a particular unique identifier in one session, it must have the same unique ID in all sessions. Once used, a given UID can never be reused even if the corresponding message is deleted.
If a specified message (corresponding to MessageNumber) does not exist or is marked for deletion, the function returns an error status.
This command is used to implement a poor man's server-based message store. Basically, a client does not automatically delete messages, after getting messages, then at the start of each session, it calls GetMessageUIDArray to obtain an array of all messages currently on the server. Any UIDs not currently known by the client are retrieved. That of course requires the client to keep track of the UIDs for all retrieved messages.
Reimplemented in POP3.
_.Library.Status GetSizeOfMessages | ( | _.Library.String | MessageNumber, |
_.Library.ArrayOfDataTypes | ListOfSizes | ||
) |
If you pass in an empty string "", an array with an element for
each of the messages not marked for deletion is returned.
Each element of the array has the message number as its index and the size of the message in bytes as its value..
If you pass in a message number, a one element array is returned. The element has the message number as its index and the size of the message in bytes as its value. An error status is returned if a message with this message number does not exist or has been marked for deletion.
Reimplemented in POP3.
_.Library.Status Ping | ( | ) |
This function is used to prevent an autologout timer from expiring
or to determine if the server is still functioning on the connection.
Reimplemented in POP3.
_.Library.Status QuitAndCommit | ( | ) |
This method ends the session of this Protocl object with the
mail server.
Also, as a side-effect, any messages marked for deletion are deleted.
This function (or its companion QuitAndRollback) must be executed before the process that issued a connect ends or havoc could be wreaked upon the mail server. (Mail servers do not have to bullet proof themselves against connects not followed by a quit.)
Reimplemented in POP3.
_.Library.Status QuitAndRollback | ( | ) |
This function calls RollbackDeletes and then quits.
<P>This method ends the session of this Protocl object with the mail server.</P> <P>This function (or its companion QuitAndCommit) must be executed before the process that issued a connect ends or havoc could be wreaked upon the mail server. (Mail servers do not have to bullet proof themselves against connects not followed by a quit.)</P>
Reimplemented in POP3.
_.Library.Status RollbackDeletes | ( | ) |
This method unmarks any messages previously marked for deletion.
Reimplemented in POP3.
AttachDir |
When receiving messages using POP3, the directory where attached files will be stored.
Connected |
Debug |
StoreAttachToFile |
We always store attachments as a part in the message.
If StoreAttachToFile=true and content-disposition MIME header of attachment part = "attachment", we ALSO store to the directory specified in AttachDir
StoreInlineToFile |
We always store attachments as a part in the message.
If StoreInlineToFile=true and content-disposition MIME header of attachment part = "inline", we ALSO store to the directory specified in AttachDir