mailReadMessage PowerScript function
Description
Opens a mail message whose ID is stored in the mail session’s
message array. You can choose to read the entire message or the
envelope (sender, date received, and so on) only. If a message has
attachments, they are stored in a temporary file. You can also choose
to have the message text written to in a temporary file.
Controls
mailSession object
Syntax
|
1 |
<span>mailsession</span>.<span>mailReadMessage</span> ( <span>messageid</span>, <span>mailmessage</span>, <span>readoption</span>, <br> <span>mark </span>) |
|
Argument |
Description |
|---|---|
|
mailsession |
A mailSession object identifying the |
|
messageid |
A string whose value is the ID of the |
|
mailmessage |
A mailMessage structure in which mailReadMessage stores |
|
readoption |
A value of the mailReadOption enumerated
|
|
mark |
A boolean indicating whether you want
|
Return Values
MailReturnCode. Returns one of the following values:
-
mailReturnSuccess!
-
mailReturnFailure!
-
mailReturnInsufficientMemory!
If any argument’s value is null, mailReadMessage returns null.
Usage
To obtain the message IDs for the messages in the user’s
inbox, call mailGetMessages.
Before calling mail functions, you must declare and create
a mailSession object and call mailLogon to establish
a mail session.
Reading attachments
If a message has an attachment and you do not suppress attachments, information
about it is stored in the AttachmentFile property of the mailMessage
object. The AttachmentFile property is a mailFileDescription object.
Its PathName property has the location of the temporary file that mailReadMessage
created for the attachment. By default, the temporary file is in
the directory specified by the TEMP environment variable.
Be sure to delete this temporary file when you no longer need
it.
Examples
In this example, mail is displayed in a window with
a DataWindow dw_inbox that lists mail
messages and a MultiLineEdit mle_note that
displays the message text. Assuming that the application has created
the mailSession object mSes and successfully
logged on, and that dw_inbox contains
a list of mail items (sender, subject, postmark, and message ID);
this script for the Clicked event for dw_inbox displays
the text of the selected message in the MultiLineEdit mle_note:
|
1 |
integer nRow, nRet |
|
1 |
string sMessageID |
|
1 |
string sRet, sName |
|
1 |
|
1 |
// Find out what Mail Item was selected |
|
1 |
nRow = GetClickedRow() |
|
1 |
IF nRow > 0 THEN |
|
1 |
// Get the message ID from the row |
|
1 |
sMessageID = GetItemString(nRow, 'MessageID') |
|
1 |
|
1 |
// Reread the message to obtain entire contents |
|
1 |
// because previously we read only the envelope |
|
1 |
mRet = mSes.<span>mailReadMessage</span>(sMessageID, mMsg & |
|
1 |
mailEntireMessage!, TRUE) |
|
1 |
|
1 |
// Display the text |
|
1 |
mle_note.Text = mMsg.NoteText |
|
1 |
END IF |
See mailGetMessages for an example that
creates a list of mail messages in a DataWindow control, the type
of setup that this example expects. See also the mail examples in
the Code Examples sample application supplied with PowerBuilder.