Skip to main content

%Net.MailMessagePart

serial class %Net.MailMessagePart extends %Library.SerialObject

For information on using this class, see Sending and Receiving Email.

Send an SMTP mail message or receive a MIME message using POP3.

Property Inventory

Method Inventory

Properties

property BinaryData as %FileBinaryStream;
binary data if message is BINARY and is NOT multipart
Property methods: BinaryDataDelete(), BinaryDataGet(), BinaryDataGetObject(), BinaryDataGetObjectId(), BinaryDataGetSwizzled(), BinaryDataIsValid(), BinaryDataNewObject(), BinaryDataOid(), BinaryDataOpen(), BinaryDataSet(), BinaryDataSetObject(), BinaryDataSetObjectId(), BinaryDataUnSwizzle()
property Charset as %String;
Then default is utf-8 on Unicode systems and the system default on 8-bit systems.

Charset determines the charset of the mail message part. %Net.SMTP and %Net.POP3 handle Charset differently -- see the appropriate class definition.
Property methods: CharsetDisplayToLogical(), CharsetGet(), CharsetIsValid(), CharsetLogicalToDisplay(), CharsetLogicalToOdbc(), CharsetNormalize()
property ContentTransferEncoding as %String (VALUELIST = ",base64,quoted-printable,7bit,8bit");
Content-Transfer-Encoding header. Can be one of "base64", "quoted-printable", "7bit", "8bit". Default is "base64 if IsBinary is true, toherwise default is "quoted-printable".
Property methods: ContentTransferEncodingDisplayToLogical(), ContentTransferEncodingGet(), ContentTransferEncodingIsValid(), ContentTransferEncodingLogicalToDisplay(), ContentTransferEncodingLogicalToOdbc(), ContentTransferEncodingNormalize()
property ContentType as %String (MAXLEN = 1024);
Sets the Content-Type header. If IsBinary, defaults to "application/octet-stream" If 'IsBinary && isHTML, defaults to "text/html" If 'IsBinary && 'isHTML, defaults to "text/plain"
Property methods: ContentTypeDisplayToLogical(), ContentTypeGet(), ContentTypeIsValid(), ContentTypeLogicalToDisplay(), ContentTypeLogicalToOdbc(), ContentTypeNormalize(), ContentTypeSet()
property Dir as %String (MAXLEN = 4096);
directory for attachments
Property methods: DirDisplayToLogical(), DirGet(), DirIsValid(), DirLogicalToDisplay(), DirLogicalToOdbc(), DirNormalize(), DirSet()
property FileName as %String (MAXLEN = 4096);
Filename if message is associated with attached file
Property methods: FileNameDisplayToLogical(), FileNameGet(), FileNameIsValid(), FileNameLogicalToDisplay(), FileNameLogicalToOdbc(), FileNameNormalize(), FileNameSet()
property Headers as array of %String (MAXLEN = 4096);
Array of header names and their values. Note that Content-Transfer-Encoding, Content-Type and Content-Disposition are automatically created and should not be included in the Headers array.
Property methods: HeadersBuildValueArray(), HeadersCollectionToDisplay(), HeadersCollectionToOdbc(), HeadersDisplayToCollection(), HeadersDisplayToLogical(), HeadersGet(), HeadersGetObject(), HeadersGetObjectId(), HeadersGetSwizzled(), HeadersIsValid(), HeadersLogicalToDisplay(), HeadersLogicalToOdbc(), HeadersNormalize(), HeadersOdbcToCollection(), HeadersSet(), HeadersSetObject(), HeadersSetObjectId()
property InlineAttachment as %Boolean;
If Filename specified and InlineAttachment property is true, then attachment will have a content-disposition header with value inline.
Property methods: InlineAttachmentDisplayToLogical(), InlineAttachmentGet(), InlineAttachmentIsValid(), InlineAttachmentLogicalToDisplay(), InlineAttachmentNormalize(), InlineAttachmentSet()
deprecated property Is7bit as %Boolean [ Calculated ];
If message is NOT multipart, this indicates whether message to be sent will be treated as a 7bit message that does not need encoding. All body text must already be 7bit data and all lines must < 998 bytes in lenght.
When sending the message and IsBase64=1, then Is7bit is ignored. Is7bit is deprecated. Use ContentTransferEncoding.
Property methods: Is7bitDisplayToLogical(), Is7bitIsValid(), Is7bitLogicalToDisplay(), Is7bitNormalize()
deprecated property IsAlternative as %Boolean [ Calculated ];
The IsAlternative property is only meaningful for multipart messages (IsMultiPart=1). If IsAlternative=1, then Content-Type: multipart/alternative, otherwise Content-Type: multipart/mixed. IsAlternative is deprecated. Use MultiPartType
Property methods: IsAlternativeDisplayToLogical(), IsAlternativeIsValid(), IsAlternativeLogicalToDisplay(), IsAlternativeNormalize()
deprecated property IsBase64 as %Boolean [ Calculated ];
If message is NOT multipart, this indicates whether message to be sent will be encoded as Base64 or quoted-printable.
When sending the message and Is7bit="", the encoding (IsBase64) defaults to 1 if IsBinary, else to 0. IsBase64 is deprecated. Use ContentTransferEncoding.
Property methods: IsBase64DisplayToLogical(), IsBase64IsValid(), IsBase64LogicalToDisplay(), IsBase64Normalize()
property IsBinary as %Boolean;
If message is NOT multipart, this indicates whether message has text or binary data
Property methods: IsBinaryDisplayToLogical(), IsBinaryGet(), IsBinaryIsValid(), IsBinaryLogicalToDisplay(), IsBinaryNormalize(), IsBinarySet()
property IsHTML as %Boolean;
if message is NOT multipart and is text, this indicates whether message is in HTML format
Property methods: IsHTMLDisplayToLogical(), IsHTMLGet(), IsHTMLIsValid(), IsHTMLLogicalToDisplay(), IsHTMLNormalize(), IsHTMLSet()
property IsMultiPart as %Boolean [ InitialExpression = 0 ];
If set, this message part (which may be the entire message) is made up out of parts which you need to process. If 0, then message consists of a single part and either has text data or binary data
Property methods: IsMultiPartDisplayToLogical(), IsMultiPartGet(), IsMultiPartIsValid(), IsMultiPartLogicalToDisplay(), IsMultiPartNormalize(), IsMultiPartSet()
property MultiPartType as %String;
Type of MultiPart to declare, e.g. "related","alternative"; default="mixed"
Property methods: MultiPartTypeDisplayToLogical(), MultiPartTypeGet(), MultiPartTypeIsValid(), MultiPartTypeLogicalToDisplay(), MultiPartTypeLogicalToOdbc(), MultiPartTypeNormalize(), MultiPartTypeSet()
property Parts as array of %Net.MailMessagePart;
If IsMultiPart=1 (true), Parts is an array of the parts of a multipart messsage. Normally each of these parts is a %Net.MailMessagePart.

However, if ContentType="message/rfc822", then Parts may only have one entry which is a %Net.MailMessage object that represents an attached email message. This attached message may be converted to a %Net.MailMessage object using the GetAttachedEmail method of %Net.POP3.
Property methods: PartsBuildValueArray(), PartsCollectionToDisplay(), PartsCollectionToOdbc(), PartsDisplayToCollection(), PartsGet(), PartsGetObject(), PartsGetObjectId(), PartsGetSwizzled(), PartsIsValid(), PartsOdbcToCollection(), PartsSet(), PartsSetObject(), PartsSetObjectId()
property TextData as %FileCharacterStream;
text data if message is NOT binary and is NOT multipart
Property methods: TextDataDelete(), TextDataGet(), TextDataGetObject(), TextDataGetObjectId(), TextDataGetSwizzled(), TextDataIsValid(), TextDataNewObject(), TextDataOid(), TextDataOpen(), TextDataSet(), TextDataSetObject(), TextDataSetObjectId(), TextDataUnSwizzle()

Methods

method %OnNew(charset As %String = "") as %Status
Inherited description: This callback method is invoked by the %New() method to provide notification that a new instance of an object is being created.

If this method returns an error then the object will not be created.

It is passed the arguments provided in the %New call. When customizing this method, override the arguments with whatever variables and types you expect to receive from %New(). For example, if you're going to call %New, passing 2 arguments, %OnNew's signature could be:

Method %OnNew(dob as %Date = "", name as %Name = "") as %Status If instead of returning a %Status code this returns an oref and this oref is a subclass of the current class then this oref will be the one returned to the caller of %New method.

method AttachEmail(mailmsg As %Net.MailMessage)
Attach email message to current message.
method AttachFile(Dir As %String, File As %String, isBinary As %Boolean = 1, charset As %String = "", ByRef count As %Integer) as %Status
Attach file to this message as another MIME part. All files are sent as binary attachments by default. However, a text file may be attached by passing the third argument, isBinary, as 0. For text files, the charset may be passed as the fourth argument.
The position in the Parts array of the message part that holds the file is returned in the count reference argument. This count may be used to set additional characteristics of the file such as Charset, e.g. set msg.Parts.GetAt(count).Charset="iso-8859-1".
For example to send the file as a text file in charset iso-8859-2:
  set status=message.AttachFile("d:\temp","test.txt",0,"iso-8859-1",.count)
  if $$$ISERR(status) do handleError .....
  
Note that setting the Charset does not translate the file. Rather it just specifies the charset that already describes the file's data.
method AttachNewMessage() as %Net.MailMessagePart
Attach message to current message. Return oref of attached message, so more things can be attached to the attachment
method AttachStream(stream As %Stream.Object, Filename As %String, isBinary As %Boolean = 1, charset As %String = "", ByRef count As %Integer) as %Status
Attach the contents of a stream to this message as another MIME part. The attachment is considered a file attachment if Filename is specified. Otherwise it is considered an inline attachment. All attachments are sent as binary attachments by default. However, a text attached may be attached by passing the third argument, isBinary, as 0. For text attachments, the charset may be passed as the fourth argument.
The position in the Parts array of the message part that holds the file is returned in the count reference argument. This count may be used to set additional characteristics of the file such as Charset, e.g. set msg.Parts.GetAt(count).Charset="iso-8859-1".
For example to send the attachememt as a text file in charset iso-8859-2:
  set status=message.AttachFile(myCharacterStream,"test.txt",0,"iso-8859-1",.count)
  if $$$ISERR(status) do handleError .....
  
Note that setting the Charset does not translate the attachment. Rather it just specifies the charset that already describes the file's data.
method CharsetSet(charset As %String) as %Status
method ContentTransferEncodingSet(value As %String) as %Status
method GetAttribute(header As %String, name As %String) as %String

Call this method with a header value, for example, "content-disposition" and the name of an attribute, for example, "filename" to obtain the value of the MIME attribute for this message part.

This only works after a message has been received in POP3 not when a message is being composed in SMTP.

method GetFileName() as %String
If message is associated with an attached file, get the filename
method Is7bitGet() as %Boolean
method Is7bitSet(value As %Boolean) as %Status
method IsAlternativeGet() as %Boolean
method IsAlternativeSet(value As %Boolean) as %Status
method IsBase64Get() as %Boolean
method IsBase64Set(value As %Boolean) as %Status

Inherited Members

Inherited Methods

Subclasses

FeedbackOpens in a new tab