MapiMessage

Inheritance: java.lang.Object, com.aspose.email.MapiPropertyContainer, com.aspose.email.MapiMessageItemBase

public final class MapiMessage extends MapiMessageItemBase

Represents an Outlook Message format document that can be parsed.


The following exmaple demonstrates how to read Outlook Message files.

[Java]

//Open Outlook Message files
  MapiMessage msg = MapiMessage.fromFile("outlookmessage.msg");

  //read subject
  System.out.print("Subject:" + msg.getSubject());

  //sender name
  System.out.print("From:" + msg.getSenderName());

  //message body
  System.out.print("Body:" + msg.getBody());

  //Attachments
  for(MapiAttachment att : msg.getAttachments())
  {
      System.out.print("Attachment Name:"+att.getFileName());
      att.save(att.getFileName());
  }

Instances of the MapiMessage class are used to represent Microsoft Outlook Message document files that are parsed by MapiMessageReader class. To access the sender, recipient, and contents of an e-mail message, use the associated properties of the MapiMessage class.

Constructors

Constructor Description
MapiMessage() Initializes a new instance of the MapiMessage class.
MapiMessage(int format) Initializes a new instance of the MapiMessage class.
MapiMessage(String from, String to, String subject, String body, int format) Initializes a new instance of the MapiMessage class.
MapiMessage(String from, String to, String subject, String body) Initializes a new instance of the MapiMessage class.

Methods

Method Description
getBody() Gets the message text.
setBody(String value) Gets the message text.
getReplyTo() Gets or sets the reply to names.
setReplyTo(String value) Gets or sets the reply to names.
getNormalizedSubject() Gets normalized subject of the message.
getDisplayTo() Gets a list of the display names of the primary (To) message recipients, separated by semicolons (;).
getDisplayNamePrefix() Gets a prefix of the display name.
getDisplayName() Gets the display name for the message.
getDisplayCc() Gets a list of the display names of any carbon copy (CC) message recipients, separated by semicolons (;).
getDisplayBcc() Gets a list of the display names of any blind carbon copy (BCC) message recipients, separated by semicolons (;).
getSenderEmailAddress() Gets or sets the message sender’s e-mail address.
setSenderEmailAddress(String value) Gets or sets the message sender’s e-mail address.
getSenderSmtpAddress() Gets or sets the message sender’s e-mail address.
setSenderSmtpAddress(String value) Gets or sets the message sender’s e-mail address.
getSenderAddressType() Gets the message sender’s e-mail address type.
getSenderName() Gets or sets the message sender’s display name.
setSenderName(String value) Gets or sets the message sender’s display name.
getTransportMessageHeaders() Gets the transport-specific message envelope information.
getInternetMessageId() Gets the message id of the message.
getConversationTopic() Gets the topic of the first message in a conversation thread.
getSentRepresentingEmailAddress() Gets or sets the e-mail address for the messaging user represented by the sender.
setSentRepresentingEmailAddress(String value) Gets or sets the e-mail address for the messaging user represented by the sender.
getSentRepresentingSmtpAddress() Gets or sets the e-mail address for the messaging user represented by the sender.
getSentRepresentingAddressType() Gets the address type for the messaging user represented by the sender.
getSentRepresentingName() Gets or sets the display name for the messaging user represented by the sender.
setSentRepresentingName(String value) Gets or sets the display name for the messaging user represented by the sender.
getClientSubmitTime() Gets or sets the date and time the message sender submitted a message.
setClientSubmitTime(Date value) Gets or sets the date and time the message sender submitted a message.
getDeliveryTime() Gets or sets the date and time a message was delivered.
setDeliveryTime(Date value) Gets or sets the date and time a message was delivered.
getHeaders() Gets the transport message headers
setHeaders(HeaderCollection value) Gets the transport message headers
getFlags() Gets the message flags.
getReadReceiptRequested() Gets or sets a value indicating whether the read receipt is requested.
setReadReceiptRequested(boolean value) Gets or sets a value indicating whether the read receipt is requested.
getMessageFormat() Gets the outlook message format.
load(String fileName) Loads message from file.
load(InputStream stream) Loads message from stream.
load(InputStream stream, LoadOptions options) Loads message from stream with additional options.
load(String fileName, LoadOptions options) Loads message from file with additional options.
fromFile(String path) Create an instance of MapiMessage from the specified file.
fromStream(InputStream stream) Create an instance of MapiMessage from the specified stream.
fromProperties(MapiPropertyCollection properties) Creates an instance of MapiMessage from a collection of Mapi properties.
fromMailMessage(String fileName) Creates an instance of MapiMessage from the MailMessage.
fromMailMessage(MailMessage message) Creates an instance of MapiMessage from the MailMessage.
fromMailMessage(MailMessage message, MapiConversionOptions options) Creates an instance of MapiMessage from the MailMessage.
removeAttachments(String path) Removes all of the attachments from the specified Outlook Message files.
destroyAttachments(String path) Destroies the attachments in the specified Outlook Message files.
loadFromTnef(InputStream stream) Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
loadFromTnef(String fileName) Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
isMsgFormat(String fileName) Determines whether the specified file has a MSG format.
isMsgFormat(InputStream stream) Determines whether the specified stream has a MSG format.
setStringPropertyValue(long tag, String value) Sets the string property value.
addCustomProperty(MapiProperty property, String stringNameId) Adds the custom property.
addCustomProperty(int type, byte[] data, String stringNameId) Adds the custom property.
getCustomProperties() Gets collection of custom MapiProperties.
toMapiMessageItem() Convert MapiMessage to IMapiMessageItem object in dependence with MessageClass.
toMailMessage(MailConversionOptions options) Creates an instance of MailMessage from this MapiMessage.
save(String fileName, SaveOptions options) Saves message as a file with additional options.
save(OutputStream stream, SaveOptions options) Saves message as a stream with additional options.
saveAsTnef(OutputStream stream) Save message in TNEF format.
saveAsTnef(String fileName) Save message in TNEF format.
save(String fileName) Saves to the specified file as Msg.
saveAsTemplate(String fileName) Saves to the specified file as Outlook File Template(OFT format).
save(OutputStream stream) Saves to the specified stream as Msg.
saveAsTemplate(OutputStream stream) Saves to the specified stream as Outlook File Template(OFT format).
checkBounced() Checks whether this message can be treated as a bounce message.
deepClone() Creates a new object that is a copy of the current instance.
setProperty(MapiAttachment value, long signed, long key) Sets the attachment.
setProperty(MapiRecipient value, long signed, long key) Sets the recipient.

MapiMessage()

public MapiMessage()

Initializes a new instance of the MapiMessage class.

MapiMessage(int format)

public MapiMessage(int format)

Initializes a new instance of the MapiMessage class.

Parameters:

Parameter Type Description
format int Defines whether to use Unicode or ASCII encoding for this message.

MapiMessage(String from, String to, String subject, String body, int format)

public MapiMessage(String from, String to, String subject, String body, int format)

Initializes a new instance of the MapiMessage class.

Parameters:

Parameter Type Description
from java.lang.String The From address.
to java.lang.String The addresses of recipients. Note, that addresses are separated by semicolon.
subject java.lang.String The message subject.
body java.lang.String The message body.
format int Defines whether to use Unicode or ASCII encoding for this message.

MapiMessage(String from, String to, String subject, String body)

public MapiMessage(String from, String to, String subject, String body)

Initializes a new instance of the MapiMessage class.

Parameters:

Parameter Type Description
from java.lang.String The From address.
to java.lang.String The addresses of recipients. Note, that addresses are separated by semicolon.
subject java.lang.String The message subject.
body java.lang.String The message body.

getBody()

public final String getBody()

Gets the message text.

Value: The string that represents message body.

Returns: java.lang.String

setBody(String value)

public final void setBody(String value)

Gets the message text.

Value: The string that represents message body.

Parameters:

Parameter Type Description
value java.lang.String

getReplyTo()

public final String getReplyTo()

Gets or sets the reply to names.

Returns: java.lang.String

setReplyTo(String value)

public final void setReplyTo(String value)

Gets or sets the reply to names.

Parameters:

Parameter Type Description
value java.lang.String

getNormalizedSubject()

public final String getNormalizedSubject()

Gets normalized subject of the message.

Value: The string that represents normalized subject.

Returns: java.lang.String

getDisplayTo()

public final String getDisplayTo()

Gets a list of the display names of the primary (To) message recipients, separated by semicolons (;).

Value: The string that represents display to.

Returns: java.lang.String

getDisplayNamePrefix()

public final String getDisplayNamePrefix()

Gets a prefix of the display name.

Value: The string that represents display name prefix.

Returns: java.lang.String

getDisplayName()

public final String getDisplayName()

Gets the display name for the message.

Value: The string that represents display name.

Returns: java.lang.String

getDisplayCc()

public final String getDisplayCc()

Gets a list of the display names of any carbon copy (CC) message recipients, separated by semicolons (;).

Value: The string that represents display cc.

Returns: java.lang.String

getDisplayBcc()

public final String getDisplayBcc()

Gets a list of the display names of any blind carbon copy (BCC) message recipients, separated by semicolons (;).

Value: The string that represents display bcc.

Returns: java.lang.String

getSenderEmailAddress()

public final String getSenderEmailAddress()

Gets or sets the message sender’s e-mail address.

Returns: java.lang.String

setSenderEmailAddress(String value)

public final void setSenderEmailAddress(String value)

Gets or sets the message sender’s e-mail address.

Parameters:

Parameter Type Description
value java.lang.String

getSenderSmtpAddress()

public final String getSenderSmtpAddress()

Gets or sets the message sender’s e-mail address.

Returns: java.lang.String

setSenderSmtpAddress(String value)

public final void setSenderSmtpAddress(String value)

Gets or sets the message sender’s e-mail address.

Parameters:

Parameter Type Description
value java.lang.String

getSenderAddressType()

public final String getSenderAddressType()

Gets the message sender’s e-mail address type.

Value: The string that represents sender address type.

Returns: java.lang.String

getSenderName()

public final String getSenderName()

Gets or sets the message sender’s display name.

Value: The the string that represents sender name.


When setting a null value or empty string, the values of the property get the value equal to SenderEmailAddress.

Returns: java.lang.String

setSenderName(String value)

public final void setSenderName(String value)

Gets or sets the message sender’s display name.

Value: The the string that represents sender name.


When setting a null value or empty string, the values of the property get the value equal to SenderEmailAddress.

Parameters:

Parameter Type Description
value java.lang.String

getTransportMessageHeaders()

public final String getTransportMessageHeaders()

Gets the transport-specific message envelope information.

Value: The string that represents transport message headers.

Returns: java.lang.String

getInternetMessageId()

public final String getInternetMessageId()

Gets the message id of the message.

Value: The string that represents internet message id.

Returns: java.lang.String

getConversationTopic()

public final String getConversationTopic()

Gets the topic of the first message in a conversation thread.

Value: The string that represens conversation topic.

Returns: java.lang.String

getSentRepresentingEmailAddress()

public final String getSentRepresentingEmailAddress()

Gets or sets the e-mail address for the messaging user represented by the sender.

Returns: java.lang.String

setSentRepresentingEmailAddress(String value)

public final void setSentRepresentingEmailAddress(String value)

Gets or sets the e-mail address for the messaging user represented by the sender.

Parameters:

Parameter Type Description
value java.lang.String

getSentRepresentingSmtpAddress()

public final String getSentRepresentingSmtpAddress()

Gets or sets the e-mail address for the messaging user represented by the sender.

Value: The string that represents sent representing email address.

Returns: java.lang.String

getSentRepresentingAddressType()

public final String getSentRepresentingAddressType()

Gets the address type for the messaging user represented by the sender.

Value: The string that represents sent representing address type.

Returns: java.lang.String

getSentRepresentingName()

public final String getSentRepresentingName()

Gets or sets the display name for the messaging user represented by the sender.

Value: The string that represents sent representing name.


When setting a null value or empty string, the values of the property are set in SentRepresentingEmailAddress.

Returns: java.lang.String

setSentRepresentingName(String value)

public final void setSentRepresentingName(String value)

Gets or sets the display name for the messaging user represented by the sender.

Value: The string that represents sent representing name.


When setting a null value or empty string, the values of the property are set in SentRepresentingEmailAddress.

Parameters:

Parameter Type Description
value java.lang.String

getClientSubmitTime()

public final Date getClientSubmitTime()

Gets or sets the date and time the message sender submitted a message.

Value: The DateTime that represents client submit time.


If the property was not available, DateTime.MinValue is returned.

Returns: java.util.Date

setClientSubmitTime(Date value)

public final void setClientSubmitTime(Date value)

Gets or sets the date and time the message sender submitted a message.

Value: The DateTime that represents client submit time.


If the property was not available, DateTime.MinValue is returned.

Parameters:

Parameter Type Description
value java.util.Date

getDeliveryTime()

public final Date getDeliveryTime()

Gets or sets the date and time a message was delivered.

Value: The DateTime that represents delivery time.


If the property was not available, DateTime.MinValue is returned.

Returns: java.util.Date

setDeliveryTime(Date value)

public final void setDeliveryTime(Date value)

Gets or sets the date and time a message was delivered.

Value: The DateTime that represents delivery time.


If the property was not available, DateTime.MinValue is returned.

Parameters:

Parameter Type Description
value java.util.Date

getHeaders()

public final HeaderCollection getHeaders()

Gets the transport message headers

Returns: HeaderCollection

setHeaders(HeaderCollection value)

public final void setHeaders(HeaderCollection value)

Gets the transport message headers

Parameters:

Parameter Type Description
value HeaderCollection

getFlags()

public final long getFlags()

Gets the message flags.

Value: The message flags.

Returns: long

getReadReceiptRequested()

public final boolean getReadReceiptRequested()

Gets or sets a value indicating whether the read receipt is requested.

Value: ``` true ``` if the read receipt is requested; otherwise, ``` false ```.

Returns: boolean

setReadReceiptRequested(boolean value)

public final void setReadReceiptRequested(boolean value)

Gets or sets a value indicating whether the read receipt is requested.

Value: ``` true ``` if the read receipt is requested; otherwise, ``` false ```.

Parameters:

Parameter Type Description
value boolean

getMessageFormat()

public final int getMessageFormat()

Gets the outlook message format.

Value: The outlook message format.

Returns: int

load(String fileName)

public static MapiMessage load(String fileName)

Loads message from file.

Parameters:

Parameter Type Description
fileName java.lang.String Source file pathString.

Returns: MapiMessage -

load(InputStream stream)

public static MapiMessage load(InputStream stream)

Loads message from stream.

Parameters:

Parameter Type Description
stream java.io.InputStream Source streamjava.io.InputStream.

Returns: MapiMessage -

load(InputStream stream, LoadOptions options)

public static MapiMessage load(InputStream stream, LoadOptions options)

Loads message from stream with additional options.

Parameters:

Parameter Type Description
stream java.io.InputStream Source streamjava.io.InputStream.
options LoadOptions Additional options LoadOptions.

Returns: MapiMessage -

load(String fileName, LoadOptions options)

public static MapiMessage load(String fileName, LoadOptions options)

Loads message from file with additional options.

Parameters:

Parameter Type Description
fileName java.lang.String Source file pathString.
options LoadOptions Additional options LoadOptions.

Returns: MapiMessage -

fromFile(String path)

public static MapiMessage fromFile(String path)

Create an instance of MapiMessage from the specified file.

Parameters:

Parameter Type Description
path java.lang.String The name of the file to be loaded.

Returns: MapiMessage - Returns a MapiMessage instance which is loaded from the specified file.

fromStream(InputStream stream)

public static MapiMessage fromStream(InputStream stream)

Create an instance of MapiMessage from the specified stream.

Parameters:

Parameter Type Description
stream java.io.InputStream The stream to be loaded.

Returns: MapiMessage - Returns a MapiMessage instance which is loaded from the specified stream.

fromProperties(MapiPropertyCollection properties)

public static MapiMessage fromProperties(MapiPropertyCollection properties)

Creates an instance of MapiMessage from a collection of Mapi properties.

Parameters:

Parameter Type Description
properties MapiPropertyCollection A collection of MapiProperty.

Returns: MapiMessage - Returns a MapiMessage instance which is loaded from the specified properties.

fromMailMessage(String fileName)

public static MapiMessage fromMailMessage(String fileName)

Creates an instance of MapiMessage from the MailMessage.

Parameters:

Parameter Type Description
fileName java.lang.String The file name of MailMessage.

Returns: MapiMessage - Returns a MapiMessage instance which is loaded from the MailMessage.

fromMailMessage(MailMessage message)

public static MapiMessage fromMailMessage(MailMessage message)

Creates an instance of MapiMessage from the MailMessage.

Parameters:

Parameter Type Description
message MailMessage The MailMessage.

Returns: MapiMessage - Returns a MapiMessage instance which is loaded from the MailMessage.

fromMailMessage(MailMessage message, MapiConversionOptions options)

public static MapiMessage fromMailMessage(MailMessage message, MapiConversionOptions options)

Creates an instance of MapiMessage from the MailMessage.

Parameters:

Parameter Type Description
message MailMessage The MailMessage.
options MapiConversionOptions MapiFromMailMessageOptions MapiConversionOptions

Returns: MapiMessage - MapiMessage that represents Outlook message.

removeAttachments(String path)

public static MapiAttachmentCollection removeAttachments(String path)

Removes all of the attachments from the specified Outlook Message files.


The following exmaple demonstrates how to destroy attachments in Outlook Message files.

[Java]

//Remove attachments from Outlook Message files
     MapiAttachmentCollection attachments = MapiMessage.removeAttachments("outlookmessage.msg");

     //Attachments
     for(MapiAttachment att : attachments)
     {
        System.out.print("Attachment Name:"+att.getFileName());
        att.save(att.getFileName());
     }

Parameters:

Parameter Type Description
path java.lang.String The name of the Outlook Message file.

Returns: MapiAttachmentCollection - The attachments collection.

destroyAttachments(String path)

public static void destroyAttachments(String path)

Destroies the attachments in the specified Outlook Message files. DestroyAttachments will ignore the attachment parsing.


The following exmaple demonstrates how to destroy attachments in Outlook Message files.

[Java]

//Destroy attachments from Outlook Message files
     MapiMessage.destroyAttachment("outlookmessage.msg");

Parameters:

Parameter Type Description
path java.lang.String The name of the Outlook Message file.

loadFromTnef(InputStream stream)

public static MapiMessage loadFromTnef(InputStream stream)

Loads message from Transport Neutral Encapsulation Format (TNEF) data structure

Parameters:

Parameter Type Description
stream java.io.InputStream A stream representing message data in TNEF format

Returns: MapiMessage - A read MapiMessage

loadFromTnef(String fileName)

public static MapiMessage loadFromTnef(String fileName)

Loads message from Transport Neutral Encapsulation Format (TNEF) data structure

Parameters:

Parameter Type Description
fileName java.lang.String Name of file containing message data in TNEF format

Returns: MapiMessage - A read MapiMessage

isMsgFormat(String fileName)

public static boolean isMsgFormat(String fileName)

Determines whether the specified file has a MSG format.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.

Returns: boolean - ``` true ``` if the file is represented in MSG format; otherwise, ``` false ```.

isMsgFormat(InputStream stream)

public static boolean isMsgFormat(InputStream stream)

Determines whether the specified stream has a MSG format.

Parameters:

Parameter Type Description
stream java.io.InputStream The message stream.

Returns: boolean - ``` true ``` if the stream is represented in MSG format]; otherwise, ``` false ```.

setStringPropertyValue(long tag, String value)

public final void setStringPropertyValue(long tag, String value)

Sets the string property value.

Parameters:

Parameter Type Description
tag long The property tag.
value java.lang.String The property value.

addCustomProperty(MapiProperty property, String stringNameId)

public final void addCustomProperty(MapiProperty property, String stringNameId)

Adds the custom property.

Parameters:

Parameter Type Description
property MapiProperty The propertyMapiProperty.
stringNameId java.lang.String The name of propertyString.

addCustomProperty(int type, byte[] data, String stringNameId)

public final void addCustomProperty(int type, byte[] data, String stringNameId)

Adds the custom property.

Parameters:

Parameter Type Description
type int Type of MapiPropertyMapiPropertyType
data byte[] MapiProperty data.byte
stringNameId java.lang.String The name of propertyString.

getCustomProperties()

public final MapiPropertyCollection getCustomProperties()

Gets collection of custom MapiProperties.

Returns: MapiPropertyCollection - Collection of custom MapiPropertiesMapiPropertyCollection.

toMapiMessageItem()

public final IMapiMessageItem toMapiMessageItem()

Convert MapiMessage to IMapiMessageItem object in dependence with MessageClass.

Returns: IMapiMessageItem - The IMapiMessageItem interface.

toMailMessage(MailConversionOptions options)

public final MailMessage toMailMessage(MailConversionOptions options)

Creates an instance of MailMessage from this MapiMessage.

Parameters:

Parameter Type Description
options MailConversionOptions Allows to specify additional options when converting from MapiMessage to MailMessage.

Returns: MailMessage - Returns a MailMessage instance which is loaded from this MapiMessage.

save(String fileName, SaveOptions options)

public final void save(String fileName, SaveOptions options)

Saves message as a file with additional options.

Parameters:

Parameter Type Description
fileName java.lang.String Stream into which message is saved.
options SaveOptions Additional options for savingSaveOptions.

save(OutputStream stream, SaveOptions options)

public final void save(OutputStream stream, SaveOptions options)

Saves message as a stream with additional options.

Parameters:

Parameter Type Description
stream java.io.OutputStream Stream into which message is saved.
options SaveOptions Additional options for savingSaveOptions.

saveAsTnef(OutputStream stream)

public final void saveAsTnef(OutputStream stream)

Save message in TNEF format.

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream where a message will be saved to.

saveAsTnef(String fileName)

public final void saveAsTnef(String fileName)

Save message in TNEF format.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file where a message will be saved to.

save(String fileName)

public final void save(String fileName)

Saves to the specified file as Msg.

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.

saveAsTemplate(String fileName)

public final void saveAsTemplate(String fileName)

Saves to the specified file as Outlook File Template(OFT format).

Parameters:

Parameter Type Description
fileName java.lang.String Name of the file.

save(OutputStream stream)

public final void save(OutputStream stream)

Saves to the specified stream as Msg.

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream.

saveAsTemplate(OutputStream stream)

public final void saveAsTemplate(OutputStream stream)

Saves to the specified stream as Outlook File Template(OFT format).

Parameters:

Parameter Type Description
stream java.io.OutputStream The stream.

checkBounced()

public final BounceResult checkBounced()

Checks whether this message can be treated as a bounce message.

Returns: BounceResult - Result of checkingBounceResult.

deepClone()

public final MapiMessage deepClone()

Creates a new object that is a copy of the current instance.

Returns: MapiMessage - A new object that is a copy of this instance.

setProperty(MapiAttachment value, long signed, long key)

public void setProperty(MapiAttachment value, long signed, long key)

Sets the attachment.

Parameters:

Parameter Type Description
value MapiAttachment The property value.
signed long The value, that indicates that the property is signed.
key long The property tag.

setProperty(MapiRecipient value, long signed, long key)

public void setProperty(MapiRecipient value, long signed, long key)

Sets the recipient.

Parameters:

Parameter Type Description
value MapiRecipient The property value.
signed long The value, that indicates that the property is signed.
key long The property tag.