Skip to main content

Specifying the Message Headers

Specifying the Message Headers

As noted previously, both the message itself and each part of a message has a set of headers.

The %Net.MailMessageOpens in a new tab and %Net.MailMessagePartOpens in a new tab classes provide properties that give you easy access to the most commonly used headers, but you can add any header you need. This section provides information on all the headers as well as how to create custom headers.

Note:

The headers of a given message part are in the character set specified by the Charset property of that part.

Basic Headers

Set the following properties (only in %Net.MailMessageOpens in a new tab) to specify the most commonly used headers of the message itself:

  • To — (Required) The list of email addresses to which this message will be sent. This property is a standard InterSystems IRIS list; to work with it, you use the standard list methods: Insert(), GetAt(), RemoveAt(), Count(), and Clear().

  • From — (Required) The email address this message is sent from.

  • Date — The date of this message.

  • Subject — A string containing the subject for this message.

  • Sender — The actual sender of the message.

  • Cc — The list of carbon copy addresses to which this message will be sent.

  • Bcc — The list of blind carbon copy addresses to which this message will be sent.

Note:

You should be aware of the requirements of the SMTP server that you are using. For example, some SMTP servers require that you include a Subject: header. Similarly, some SMTP servers do not permit arbitrary From: headers.

Content-Type Header

When you send the message, the Content-Type header for the message and for each message part is automatically set as follows:

  • If the message is plain text (IsHTML equals 0 and IsBinary equals 0), the Content-Type header is set to "text/plain".

  • If the message is HTML (IsHTML equals 1 and IsBinary equals 0), the Content-Type header is set to "text/html".

  • If the message is binary (IsBinary equals 1), the Content-Type header is set to "application/octet-stream".

  • If the message is multipart, the Content-Type header is set as appropriate for the value of the MultiPartType property.

Both %Net.MailMessageOpens in a new tab and %Net.MailMessagePartOpens in a new tab provide the ContentType property, which gives you access to the Content-Type header.

Content-Transfer-Encoding Header

Both %Net.MailMessageOpens in a new tab and %Net.MailMessagePartOpens in a new tab provide the ContentTransferEncoding property, which provides an easy way to specify the Content-Transfer-Encoding header of the message or the message part.

This property can be one of the following: "base64" "quoted-printable" "7bit" "8bit"

The default is as follows:

  • For a binary message or message part: "base64"

  • For a text message or message part: "quoted-printable"

Custom Headers

With both %Net.MailMessageOpens in a new tab and %Net.MailMessagePartOpens in a new tab, you can set or get custom headers by accessing the Headers property, which is an array with the following structure:

Array Key Array Value
Name of the header, such as "Priority" Value of the header

You use this property to contain additional headers such as priority. For example:

 Do msg.Headers.SetAt("Urgent","Priority")
FeedbackOpens in a new tab