mailGetMessages

Description

Populates the messageID array of a mailSession object with the message IDs in the user's inbox.

Applies to

mailSession object

Syntax

mailsession.mailGetMessages ( { messagetype, } { unreadonly } )

Argument

Description

mailsession

A mailSession object identifying the session in which you want to get the messages.

messagetype (optional)

A string whose value is a message type. The default message type is IPM or an empty string (""), which identifies interpersonal messages. The other standard type is IPC, which identifies hidden, interprocess messages. Your mail administrator may have established other user-defined message types.

unreadonly (optional)

A boolean value indicating you want only the IDs of unread messages. Values are:

  • TRUE -- Get IDs for unread messages only

  • FALSE -- Get IDs for all messages


Return value

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:

mailMessage msg
long n, c_row
 
mSes.mailGetMessages()
FOR n = 1 to UpperBound(mSes.MessageID[])
    mSes.mailReadMessage(mSes.MessageID[n], &
    msg, mailEnvelopeOnly!, FALSE)
    c_row = dw_1.InsertRow(0)
    dw_1.SetItem(c_row, "msgid", mSes.MessageID[n])
    dw_1.SetItem(c_row, "msgdate", msg.DateReceived)
    // Truncate subject to fit defined column size
    dw_1.SetItem(c_row, "msgsubject", &
    Left(msg.Subject, 50))
NEXT

See also

mailDeleteMessage

mailReadMessage