SetMessage

Specify the text of the message body.

SetMessage(Message "{OptionList}")

Parameters

Parameter Type Direction Description
Message string In Text of the message; maximum of 10240000 bytes
OptionList string In Associative list of key-value pairs, to a maximum of 10240 bytes. Currently, the only valid key is MIMEType, which can be set to text/HTML or text/plain.

If omitted, MIMEType="text/plain" is used.

Return Values

Values returned in $status
Value Description
0 Operation succeeded.
-18 Memory allocation error.
<0 An error occurred

Description

Use the SetMessage operation to specify the message content and its MIME type.

To specify a multi-part message with both MIME types, use SetMessage twice. For example, the following code uses the contents of both the TEXT and the HTML fields to constructs a multi-part message:

mailApiHandle->SetMessage(TEXT.MESSAGE, "")  ; plain text body
mailApiHandle->SetMessage(HTML.MESSAGE, "MIMEType=text/html")  ; HTML body

If you set the different text but the same MIMEType, the earlier text will be replaced by the later text. For example, the following code use uses the contents of the HTML field only, because the MIME type for both messages is the same:

mailApiHandle->SetMessage(TEXT.MESSAGE, "MIMEType=text/plain")  
mailApiHandle->SetMessage(HTML.MESSAGE, "MIMEType=text/plain")  

Using SetMessage

The following example specifies an HTML message using the contents of the field BODY_HTML as the message text.

variables
    handle mailApiHandle
endvariables

; create the instance handle
newinstance "UPOPMAIL", mailApiHandle

<snip>log on to server, set message header </snip>

; set the message body
mailApiHandle->SetMessage(BODY_HTML.MESSAGE.DUMMY, "MIMEType=text/html")  ; HTML body
...
<snip> send mail, clear memory, and log off mail server</snip>