MailOutBoxSendMail

function

Library: Email support, SMTP and POP3 (OMMAIL)
Include: ommail.xin

Returns: an external output object


Declaration
define external string sink function MailOutBoxSendMail
           value MailOutBox this-MailOutBox
   to      value string recipient
   subject value string subject optional initial {""}
   header  value string header-info optional

Argument definitions

this-MailOutBox
is an OMX component of type MailOutBox.
recipient
is the email address or addresses to which the message is being sent; a single address or a comma-separated list of email addresses.
subject
is an optional subject field.
header
is where you can optionally specify header information, according to the mail-header protocol.


Purpose

This function sends a mail message with the specified subject, mail header, and recipient or recipients. It returns an external output object which is used to send the body of the message. As you write to the stream, the message parts are sent out (there is no buffering of the message). Closing the stream attached to this external output object signals the end of message composition and triggers the completion of the delivery of the message. It is an error to reopen a stream attached to an external output object derived from a mail outbox object, once that stream has been closed.

Example:


    include "ommail.xin"
    process
         local stream msg
         local stream t-Error variable initial-size 0
         local MailOutBox this-MailOutBox
         set this-MailOutBox to MailOutBoxCreate name "joe" address "[email protected]"
         open msg as MailOutBoxSendMail this-MailOutBox
            to "[email protected]"
            subject "Greetings"
         MailOutBoxGetStatusReport this-MailOutBox into t-Error
         repeat over t-Error
            put #error t-Error
         again
         halt when number of t-Error > 0
         put msg "Just wanted " || "to say " || "hello." || "%n"
         close msg
         ; Note: the close action sent the msg