mailGetMessages PowerScript function
Description
Populates the messageID array of a mailSession object with
the message IDs in the user’s inbox.
Controls
mailSession object
Syntax
1 |
<span>mailsession</span>.<span>mailGetMessages</span> ( { <span>messagetype</span>, } { <span>unreadonly</span> } ) |
Argument |
Description |
---|---|
mailsession |
A mailSession object identifying the |
messagetype (optional) |
A string whose value is a message type. |
unreadonly (optional) |
A boolean value indicating you want only
|
Return Values
mailReturnCode. Returns one of the following values:
-
mailReturnSuccess!
-
mailReturnFailure!
-
mailReturnInsufficientMemory!
-
mailReturnNoMessages!
-
mailReturnUserAbort!
If any argument’s value is null, mailGetMessages returns null.
Usage
MailGetMessages only retrieves message
IDs, which it stores in the mailSession object’s MessageID
array. A message ID serves as an argument for other mail functions.
With mailReadMessage, for example, it identifies
the message you want to read.
Before calling mail functions, you must declare and create
a mailSession object and call mailLogon to establish
a mail session.
Examples
This example populates a DataWindow with the messages
in the user’s inbox. The DataWindow is defined with an
external data source and has three columns: msgid, msgdate,
and msgsubject. MailGetMessages fills
the MessageID array in the mailSession object and mailReadMessage gets
the information for each ID.
The example assumes that the application has already created
the mailSession object mSes and logged on:
1 |
mailMessage msg |
1 |
long n, c_row |
1 |
1 |
mSes.<span>mailGetMessages</span>() |
1 |
FOR n = 1 to UpperBound(mSes.MessageID[]) |
1 |
mSes.mailReadMessage(mSes.MessageID[n], & |
1 |
msg, mailEnvelopeOnly!, FALSE) |
1 |
c_row = dw_1.InsertRow(0) |
1 |
dw_1.SetItem(c_row, "msgid", mSes.MessageID[n]) |
1 |
dw_1.SetItem(c_row, "msgdate", msg.DateReceived) |
1 |
// Truncate subject to fit defined column size |
1 |
dw_1.SetItem(c_row, "msgsubject", & |
1 |
Left(msg.Subject, 50)) |
1 |
NEXT |