RTI_GetMail function
Description
This function will retrieve emails from a POP3 or IMAP server, using authenticated logins and/or Secure Sockets Layer (SSL). Users can retrieve entire emails, or headers only; and (for IMAP servers) can specify search/selection criteria.
In OpenInsight 10+, this function is now a thin wrapper around RTI_EMAIL_CLIENT. For other information, including more details on options, please see RTI_EMAIL_CLIENT.
Syntax
RTI_GetMail(mailservername, mailservertype, Username, Password, useSSL, bHeadersOnly, bSkipAttachments, searchParamNames, searchParamVals, otherOptions, errStatus)
Parameters
The function has the following parameters:
Parameter | Description |
---|---|
mailservername | The IP address of the mailserver. |
mailservertype | Specify POP (or use the equated value EMAIL_SERVER_TYPE_POP$) to indicate a POP3 connection; specify IMAP (or use the equated value EMAIL_SERVER_TYPE_IMAP$) to indicate an IMAP connection |
username | The username of the mail account. |
password | The password of the mail account. |
useSSL | A boolean flag. When TRUE$ SSL will be used when connecting to the mail server. |
bHeadersOnly | A boolean flag. When TRUE$ the message body and any attachments will NOT be retrieved. |
bSkipAttachments | A boolean flag. When TRUE$ attachments will not be retrieved. |
searchParamNames | For IMAP servers only. An @FM delimited list of recognized search parameter names, such as FROM (the sender), SINCE (date sent) or UNSEEN (for unseen messages). |
searchParamVals | For IMAP servers only. An associated @FM delimited list of parameters, corresponding with the searchParamNames. Multiple values for a particular search parameter name may be @VM delimited. |
otherOptions | A dynamic array containing a list of option names (in field 1), and the asociated option values (in field 2). Option names include "mark" (to mark the emails as read) and "delete" (to delete the selected emails). |
errStatus | Error information and details, if any, generated by the request |
Returns
The function returns the selected message(s); any error information is returned via the errStatus parameter. Multiple messages are returned @RM delimited. The fields returned per message are:
<1> From
<2> Recipient (multiple recipients are @VM delimited)
<3> Subject
<4> Body (@TM replacing CRLF$)
<5> cc (multiple cc's are @VM delimited)
<6> Headers
<7> ReplyTo (multiple reply-to addresses are @VM delimited)
<8> Content type
<9> Attachments
<10> Date
<11> Message Flags
<12> Message ID
Remarks
See Also
Example
$Insert RTI_EMAIL_EQUATES mailservername = 'pop.mailserver.com' mailserverPort='995';* use the proper port mailServer = mailServerName:':':mailserverPort username = 'my_username' password = 'my_password' useSSl = 1 headersOnly = 0 noAttachments = 0 searchParamNames = "" ;* unused with POP searchParamVals = "" ;* unused with POP otherOpts = "" errStatus = "" mailList = RTI_GetMail( mailserver, EMAIL_SERVER_TYPE_POP$, username, password, useSSl, headersOnly, noAttachments, searchParamVals, searchParamVals, otherOpts, errStatus) if mailList = "" then *Errors in errStatus end else num.messages = dcount(mailList, @RM) for each.message = 1 to num.messages this.message = field(mailList, @RM, each.message) subject = this.message<EMSG_SUBJECT$> date = this.message<EMSG_DATE$> * perform desired operations with this information next each.message end