Skip to main content

Adding Attachments

Adding Attachments

You can add attachments to an email message or message part. To do so, use the following methods of %Net.MailMessagePartOpens in a new tab or %Net.MailMessageOpens in a new tab).

Each of these methods adds the attachment to the Parts array of the original message (or message part), and automatically sets the IsMultiPart property to 1.

AttachFile
method AttachFile(Dir As %String,
                  File As %String,
                  isBinary As %Boolean = 1,
                  charset As %String = "",
                  ByRef count As %Integer) as %Status

Attaches the given file to the email message. By default the file is sent as a binary attachment, but you can specify instead that it is text. You can also specify the character set that the file uses if it is text. (For information on character sets and translation tables, see Translation Tables.)

Specifically, this method creates an instance of %Net.MailMessagePartOpens in a new tab and places the contents of the file in the BinaryData or TextData property as appropriate, and sets the Charset property and TextData.TranslateTable properties if needed. The method returns, by reference, an integer that indicates the position of this new message part within the Parts array.

This method also sets the Dir and FileName properties of the message or message part.

AttachNewMessage
method AttachNewMessage() as %Net.MailMessagePart

Creates a new instance of %Net.MailMessageOpens in a new tab, adds it to the message, and returns the newly modified parent message or message part.

AttachEmail
method AttachEmail(mailmsg As %Net.MailMessage)

Given an email message (an instance of %Net.MailMessageOpens in a new tab), this method adds it to the message.

Note:

This method sets ContentType to "message/rfc822". In this case, you cannot add any other attachments.

For examples, see the class reference for the %Net.MailMessagePartOpens in a new tab class.

FeedbackOpens in a new tab