SetBody (Email subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
Line 35: Line 35:
You can override this encoding by specifying
You can override this encoding by specifying
the <var>Encoding</var> option set to the value <code>none</code>.
the <var>Encoding</var> option set to the value <code>none</code>.
<dt><b>Name</b>
<dd>This name required parameter provides a name for the
message body or a message part.
This option is rarely used for the mail body, and it is usually ignored
by the mail client.
It is most often used for attachments, which are added with <var>[[AddPart (Email subroutine)|AddPart]]</var>.
<dt><b>Encoding</b>
<dt><b>Encoding</b>
<dd>This name required parameter
<dd>This name required parameter
Line 45: Line 53:
Specifying <code>encoding=none</code> for non-text content is
Specifying <code>encoding=none</code> for non-text content is
not recommended: the likely result is that the recipient receives corrupt data,
not recommended: the likely result is that the recipient receives corrupt data,
or otherwise the SMTP gateway may simply discard the message.
or otherwise the SMTP gateway may simply discard the message.</dl>
<dt><b>Name</b>
<dd>This name required parameter provides a name for the
message body or a message part.
This option is rarely used for the mail body, and it is usually ignored
by the mail client.
It is most often used for attachments, which are added with <var>[[AddPart (Email subroutine)|AddPart]]</var>.
</dl>
</td></tr></table>
</td></tr></table>



Revision as of 21:54, 5 March 2012

Add body content to the message (Email class)


Syntax

email:SetBody( content, [Type= string], [Name= string], [Encoding= string])

Syntax terms

email A previously declared Email object.
content A Stringlist or Longstring that contains the actual e-mail body.

If a Stringlist is passed, each item in the Stringlist is delimited with a carriage-return/line-feed (CR/LF) character pair. To override this line-ending, you can specify a non-text content type as the value of the Type optional argument. In this case, no delimiter is added at the end of an item.

If a longstring is passed, no delimiters are added to the content.

options Any combination of the following options. Each may be specified only once.
Type
This name required parameter specifies the MIME type of the content. MIME content type strings consist of a primary type and a subtype delimited by a forward slash ( / ) character, for example, text/xml. SetBody performs no validity checking, but it does distinguish between text MIME types (&ldquo;text&rdquo; is the primary type) and non-text types. If non-text, SetBody encodes the content in base64 format to ensure correct translation at SMTP gateways. You can override this encoding by specifying the Encoding option set to the value none.
Name
This name required parameter provides a name for the message body or a message part. This option is rarely used for the mail body, and it is usually ignored by the mail client. It is most often used for attachments, which are added with AddPart.
Encoding
This name required parameter forces or suppresses encoding for the attachment. Since base64 encoding is automatically enabled for any non-text content, the Encoding option is usually unnecessary. To enable base64 encoding for text content, specify encoding=base64. To disable encoding for non-text content, specify encoding=none. Specifying encoding=none for non-text content is not recommended: the likely result is that the recipient receives corrupt data, or otherwise the SMTP gateway may simply discard the message.

Usage notes

Subsequent invocations of the SetBody method completely replace any existing content.

Examples

  • The following code fragment adds HTML text to the to the body of an SMTP message:

    ... %greet is object Email %sl is object Stringlist html to %sl <html> <h1> Hello world! </h1> </html> end html %greet:SetBody(%sl, type='text/html') ...

  • For SetBody method examples, see "Basic e-mail" and "E-mail with attachment".

See also