Class Reference
IRIS for UNIX 2019.2
InterSystems: The power behind what matters   
Documentation  Search
  [ENSLIB] >  [%Net] >  [MailMessagePart]
Private  Storage   

serial class %Net.MailMessagePart extends %SerialObject

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

Inventory

Parameters Properties Methods Queries Indices ForeignKeys Triggers
19 15


Summary

Properties
BinaryData Charset ContentTransferEncoding ContentType
Dir FileName Headers InlineAttachment
Is7bit IsAlternative IsBase64 IsBinary
IsHTML IsMultiPart MultiPartType Parts
TextData

Methods
%AddToSaveSet %AddToSyncSet %ClassIsLatestVersion %ClassName
%ConstructClone %Delete %DeleteId %DispatchClassMethod
%DispatchGetModified %DispatchGetProperty %DispatchMethod %DispatchSetModified
%DispatchSetMultidimProperty %DispatchSetProperty %Extends %GetParameter
%GetSwizzleObject %IsA %IsModified %IsNull
%New %NormalizeObject %ObjectIsNull %ObjectModified
%OnBeforeAddToSync %OnDetermineClass %OnNew %Open
%OpenId %OriginalNamespace %PackageName %RemoveFromSaveSet
%ResolveConcurrencyConflict %SerializeObject %SetModified %SyncObjectIn
%SyncTransport %ValidateObject AttachEmail AttachFile
AttachNewMessage AttachStream CharsetSet ContentTransferEncodingSet
GetAttribute GetFileName Is7bitGet Is7bitSet
IsAlternativeGet IsAlternativeSet IsBase64Get IsBase64Set
LogicalToOdbc OdbcToLogical

Subclasses
%Net.MailMessage

Properties

• property BinaryData as %FileBinaryStream;
binary data if message is BINARY and is NOT multipart
• 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 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 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 Dir as %String(MAXLEN=4096);
directory for attachments
• property FileName as %String(MAXLEN=4096);
Filename if message is associated with attached file
• 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 InlineAttachment as %Boolean;
If Filename specified and InlineAttachment property is true, then attachment will have a content-disposition header with value inline.
• 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 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 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 IsBinary as %Boolean;
If message is NOT multipart, this indicates whether message has text or binary data
• property IsHTML as %Boolean;
if message is NOT multipart and is text, this indicates whether message is in HTML format
• 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 MultiPartType as %String;
Type of MultiPart to declare, e.g. "related","alternative"; default="mixed"
• 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 TextData as %FileCharacterStream;
text data if message is NOT binary and is NOT multipart

Methods

• method %OnNew(charset As %String = "") as %Status
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
This is a Set accessor method for the Charset property.
• method ContentTransferEncodingSet(value As %String) as %Status
This is a Set accessor method for the ContentTransferEncoding property.
• 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
This is a Get accessor method for the Is7bit property.
• method Is7bitSet(value As %Boolean) as %Status
This is a Set accessor method for the Is7bit property.
• method IsAlternativeGet() as %Boolean
This is a Get accessor method for the IsAlternative property.
• method IsAlternativeSet(value As %Boolean) as %Status
This is a Set accessor method for the IsAlternative property.
• method IsBase64Get() as %Boolean
This is a Get accessor method for the IsBase64 property.
• method IsBase64Set(value As %Boolean) as %Status
This is a Set accessor method for the IsBase64 property.


Copyright (c) 2019 by InterSystems Corporation. Cambridge, Massachusetts, U.S.A. All rights reserved. Confidential property of InterSystems Corporation.