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()); }
attachments, namedPropertyMappingStorage, recipients
Constructor and 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)
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. |
Modifier and Type | Method and Description |
---|---|
void |
addCustomProperty(int type,
byte[] data,
String stringNameId)
Adds the custom property.
|
void |
addCustomProperty(MapiProperty property,
String stringNameId)
Adds the custom property.
|
BounceResult |
checkBounced()
Checks whether this message can be treated as a bounce message.
|
MapiMessage |
deepClone()
Creates a new object that is a copy of the current instance.
|
static void |
destroyAttachments(String path)
Destroies the attachments in the specified Outlook Message files.
|
static MapiMessage |
fromFile(String path)
Create an instance of MapiMessage from the specified file.
|
static MapiMessage |
fromMailMessage(MailMessage message)
Creates an instance of MapiMessage from the MailMessage.
|
static MapiMessage |
fromMailMessage(MailMessage message,
MapiConversionOptions options)
Creates an instance of MapiMessage from the MailMessage.
|
static MapiMessage |
fromMailMessage(String fileName)
Creates an instance of MapiMessage from the MailMessage.
|
static MapiMessage |
fromProperties(MapiPropertyCollection properties)
Creates an instance of MapiMessage from a collection of Mapi properties.
|
static MapiMessage |
fromStream(InputStream stream)
Create an instance of MapiMessage from the specified stream.
|
String |
getBody()
Gets the message text.
|
Date |
getClientSubmitTime()
Gets or sets the date and time
the message sender submitted a message.
|
String |
getConversationTopic()
Gets the topic of the first message in a conversation thread.
|
MapiPropertyCollection |
getCustomProperties()
Gets collection of custom MapiProperties.
|
Date |
getDeliveryTime()
Gets or sets the date and time
a message was delivered.
|
String |
getDisplayBcc()
Gets a list of the display names of any blind carbon copy (BCC) message recipients, separated by semicolons (;).
|
String |
getDisplayCc()
Gets a list of the display names of any carbon copy (CC) message recipients, separated by semicolons (;).
|
String |
getDisplayName()
Gets the display name for the message.
|
String |
getDisplayNamePrefix()
Gets a prefix of the display name.
|
String |
getDisplayTo()
Gets a list of the display names of the primary (To) message recipients, separated by semicolons (;).
|
long |
getFlags()
Gets the message flags.
|
HeaderCollection |
getHeaders()
Gets the transport message headers
|
String |
getInternetMessageId()
Gets the message id of the message.
|
int |
getMessageFormat()
Gets the outlook message format.
|
String |
getNormalizedSubject()
Gets normalized subject of the message.
|
boolean |
getReadReceiptRequested()
Gets or sets a value indicating whether the read receipt is requested.
|
String |
getReplyTo()
Gets or sets the reply to names.
|
String |
getSenderAddressType()
Gets the message sender's e-mail address type.
|
String |
getSenderEmailAddress()
Gets or sets the message sender's e-mail address.
|
String |
getSenderName()
Gets or sets the message sender's display name.
|
String |
getSenderSmtpAddress()
Gets or sets the message sender's e-mail address.
|
String |
getSentRepresentingAddressType()
Gets the address type for the messaging user represented by the sender.
|
String |
getSentRepresentingEmailAddress()
Gets or sets the e-mail address for the messaging user represented by the sender.
|
String |
getSentRepresentingName()
Gets or sets the display name for the messaging user represented by the sender.
|
String |
getSentRepresentingSmtpAddress()
Gets or sets the e-mail address for the messaging user represented by the sender.
|
String |
getTransportMessageHeaders()
Gets the transport-specific message envelope information.
|
static boolean |
isMsgFormat(InputStream stream)
Determines whether the specified stream has a MSG format.
|
static boolean |
isMsgFormat(String fileName)
Determines whether the specified file has a MSG format.
|
static MapiMessage |
load(InputStream stream,
LoadOptions options)
Loads message from stream with additional options.
|
static MapiMessage |
load(String fileName,
LoadOptions options)
Loads message from file with additional options.
|
static MapiMessage |
loadFromTnef(InputStream stream)
Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
|
static MapiMessage |
loadFromTnef(String fileName)
Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
|
static MapiAttachmentCollection |
removeAttachments(String path)
Removes all of the attachments from the specified Outlook Message files.
|
void |
save(OutputStream stream)
Saves to the specified stream as Msg.
|
void |
save(OutputStream stream,
SaveOptions options)
Saves message as a stream with additional options.
|
void |
save(String fileName)
Saves to the specified file as Msg.
|
void |
save(String fileName,
SaveOptions options)
Saves message as a file with additional options.
|
void |
saveAsTemplate(OutputStream stream)
Saves to the specified stream as Outlook File Template(OFT format).
|
void |
saveAsTemplate(String fileName)
Saves to the specified file as Outlook File Template(OFT format).
|
void |
saveAsTnef(OutputStream stream)
Save message in TNEF format.
|
void |
saveAsTnef(String fileName)
Save message in TNEF format.
|
void |
setBody(String value)
Gets the message text.
|
void |
setClientSubmitTime(Date value)
Gets or sets the date and time
the message sender submitted a message.
|
void |
setDeliveryTime(Date value)
Gets or sets the date and time
a message was delivered.
|
void |
setHeaders(HeaderCollection value)
Gets the transport message headers
|
void |
setProperty(MapiAttachment value,
long signed,
long key)
Sets the attachment.
|
void |
setProperty(MapiRecipient value,
long signed,
long key)
Sets the recipient.
|
void |
setReadReceiptRequested(boolean value)
Gets or sets a value indicating whether the read receipt is requested.
|
void |
setReplyTo(String value)
Gets or sets the reply to names.
|
void |
setSenderEmailAddress(String value)
Gets or sets the message sender's e-mail address.
|
void |
setSenderName(String value)
Gets or sets the message sender's display name.
|
void |
setSenderSmtpAddress(String value)
Gets or sets the message sender's e-mail address.
|
void |
setSentRepresentingEmailAddress(String value)
Gets or sets the e-mail address for the messaging user represented by the sender.
|
void |
setSentRepresentingName(String value)
Gets or sets the display name for the messaging user represented by the sender.
|
void |
setStringPropertyValue(long tag,
String value)
Sets the string property value.
|
MailMessage |
toMailMessage(MailConversionOptions options)
Creates an instance of MailMessage from this MapiMessage.
|
IMapiMessageItem |
toMapiMessageItem()
Convert MapiMessage to IMapiMessageItem object
in dependence with MessageClass.
|
checkIsDisposed, dispose, getAttachments, getBilling, getBodyHtml, getBodyRtf, getBodyType, getCategories, getCompanies, getItemId, getMessageClass, getMileage, getNamedProperties, getNamedPropertyMapping, getProperty, getPropertyStream, getRecipients, getSensitivity, getSubject, getSubjectPrefix, getSubStorages, initNamedPropertyMappingStorage, removeProperty, setBilling, setBodyContent, setBodyRtf, setCategories, setCompanies, setMessageClass, setMessageFlags, setMileage, setNamedPropertyMapping, setProperty, setRecipients, setSensitivity, setsIMapiMessageItemMembers, setSubject
createMapiNode, getCodePage, getProperties, getPropertyBoolean, getPropertyBytes, getPropertyDateTime, getPropertyInt32, getPropertyLong, getPropertyShort, getPropertyString, getPropertyString, isStoreUnicodeOk, setProperty, tryGetPropertyData, tryGetPropertyDateTime, tryGetPropertyInt32, tryGetPropertyLong, tryGetPropertyString, tryGetPropertyString, tryGetPropertyString, tryGetPropertyString
public MapiMessage()
Initializes a new instance of the MapiMessage
class.
public MapiMessage(int format)
Initializes a new instance of the MapiMessage
class.
format
- Defines whether to use Unicode or ASCII encoding for this message.public MapiMessage(String from, String to, String subject, String body, int format)
Initializes a new instance of the MapiMessage
class.
from
- The From address.to
- The addresses of recipients. Note, that addresses are separated by semicolon.subject
- The message subject.body
- The message body.format
- Defines whether to use Unicode or ASCII encoding for this message.com.aspose.ms.System.ArgumentNullException
- Is being thrown if address of recipient is null or empty.com.aspose.ms.System.ArgumentException
- Is being thrown if sender or recipient address is not in a recognized format.com.aspose.ms.System.ComponentModel.InvalidEnumArgumentException
- Is being thrown if format
parameter is not a valid enumeration member.public MapiMessage(String from, String to, String subject, String body)
Initializes a new instance of the MapiMessage
class.
from
- The From address.to
- The addresses of recipients. Note, that addresses are separated by semicolon.subject
- The message subject.body
- The message body.com.aspose.ms.System.ArgumentNullException
- throws if address of recipient is null or empty.com.aspose.ms.System.ArgumentException
- throws if sender or recipient address is not in a recognized format.public final String getBody()
Gets the message text.
Value: The string that represents message body.getBody
in interface IMapiMessageItem
getBody
in class MapiMessageItemBase
public final void setBody(String value)
Gets the message text.
Value: The string that represents message body.setBody
in interface IMapiMessageItem
setBody
in class MapiMessageItemBase
public final String getReplyTo()
Gets or sets the reply to names.
com.aspose.ms.System.ArgumentNullException
- throws if reply to address is null.com.aspose.ms.System.ArgumentException
- throws if reply to address is not in a recognized format.
Value: The reply to names.public final void setReplyTo(String value)
Gets or sets the reply to names.
com.aspose.ms.System.ArgumentNullException
- throws if reply to address is null.com.aspose.ms.System.ArgumentException
- throws if reply to address is not in a recognized format.
Value: The reply to names.public final String getNormalizedSubject()
Gets normalized subject of the message.
Value: The string that represents normalized subject.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.public final String getDisplayNamePrefix()
Gets a prefix of the display name.
Value: The string that represents display name prefix.public final String getDisplayName()
Gets the display name for the message.
Value: The string that represents display name.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.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.public final String getSenderEmailAddress()
Gets or sets the message sender's e-mail address.
com.aspose.ms.System.ArgumentException
- throws if sender address is not in a recognized format.
Value:
The string that represents sender email address.
public final void setSenderEmailAddress(String value)
Gets or sets the message sender's e-mail address.
com.aspose.ms.System.ArgumentException
- throws if sender address is not in a recognized format.
Value:
The string that represents sender email address.
public final String getSenderSmtpAddress()
Gets or sets the message sender's e-mail address.
com.aspose.ms.System.ArgumentException
- throws if sender address is not in a recognized format.
Value:
The string that represents sender email address.
public final void setSenderSmtpAddress(String value)
Gets or sets the message sender's e-mail address.
com.aspose.ms.System.ArgumentException
- throws if sender address is not in a recognized format.
Value:
The string that represents sender email address.
public final String getSenderAddressType()
Gets the message sender's e-mail address type.
Value: The string that represents sender address type.public final String getSenderName()
Gets or sets the message sender's display name.
Value: The the string that represents sender name.public final void setSenderName(String value)
Gets or sets the message sender's display name.
Value: The the string that represents sender name.public final String getTransportMessageHeaders()
Gets the transport-specific message envelope information.
Value: The string that represents transport message headers.public final String getInternetMessageId()
Gets the message id of the message.
Value: The string that represents internet message id.public final String getConversationTopic()
Gets the topic of the first message in a conversation thread.
Value: The string that represens conversation topic.public final String getSentRepresentingEmailAddress()
Gets or sets the e-mail address for the messaging user represented by the sender.
com.aspose.ms.System.ArgumentException
- throws if email address is not in a recognized format.
Value:
The string that represents sent representing email address.
public final void setSentRepresentingEmailAddress(String value)
Gets or sets the e-mail address for the messaging user represented by the sender.
com.aspose.ms.System.ArgumentException
- throws if email address is not in a recognized format.
Value:
The string that represents sent representing email address.
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.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.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.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.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.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.public final Date getDeliveryTime()
Gets or sets the date and time a message was delivered.
Value: The DateTime that represents delivery time.public final void setDeliveryTime(Date value)
Gets or sets the date and time a message was delivered.
Value: The DateTime that represents delivery time.public final HeaderCollection getHeaders()
Gets the transport message headers
public final void setHeaders(HeaderCollection value)
Gets the transport message headers
public final long getFlags()
Gets the message flags.
Value: The message flags.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
.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
.public final int getMessageFormat()
Gets the outlook message format.
Value: The outlook message format.public static MapiMessage load(InputStream stream, LoadOptions options)
Loads message from stream with additional options.
stream
- Source streamInputStream
.options
- Additional options LoadOptions
.FormatNotSupportedException
- Passed message format is not supported.com.aspose.ms.System.ArgumentNullException
- Stream should not be null or empty.com.aspose.ms.System.NotSupportedException
- Stream does not support reading.public static MapiMessage load(String fileName, LoadOptions options)
Loads message from file with additional options.
fileName
- Source file pathString
.options
- Additional options LoadOptions
.com.aspose.ms.System.ArgumentNullException
- File name should not be null or empty.com.aspose.ms.System.NotSupportedException
- Stream does not support reading.FormatNotSupportedException
- Passed message format is not supported.public static MapiMessage fromFile(String path)
Create an instance of MapiMessage from the specified file.
path
- The name of the file to be loaded.public static MapiMessage fromStream(InputStream stream)
Create an instance of MapiMessage from the specified stream.
stream
- The stream to be loaded.public static MapiMessage fromProperties(MapiPropertyCollection properties)
Creates an instance of MapiMessage from a collection of Mapi properties.
properties
- A collection of MapiProperty.public static MapiMessage fromMailMessage(String fileName)
Creates an instance of MapiMessage from the MailMessage.
fileName
- The file name of MailMessage.public static MapiMessage fromMailMessage(MailMessage message)
Creates an instance of MapiMessage from the MailMessage.
message
- The MailMessage.public static MapiMessage fromMailMessage(MailMessage message, MapiConversionOptions options)
Creates an instance of MapiMessage from the MailMessage.
message
- The MailMessage.options
- MapiFromMailMessageOptions MapiConversionOptions
MapiMessage
that represents Outlook message.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()); }
path
- The name of the Outlook Message file.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");
path
- The name of the Outlook Message file.public static MapiMessage loadFromTnef(InputStream stream)
Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
stream
- A stream representing message data in TNEF formatMapiMessage
com.aspose.ms.System.ArgumentNullException
- stream
is null
com.aspose.ms.System.NotSupportedException
- stream
does not support readingpublic static MapiMessage loadFromTnef(String fileName)
Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
fileName
- Name of file containing message data in TNEF formatMapiMessage
com.aspose.ms.System.ArgumentException
- fileName
is null
or empty
public static boolean isMsgFormat(String fileName)
Determines whether the specified file has a MSG format.
fileName
- Name of the file.true
if the file is represented in MSG format; otherwise, false
.public static boolean isMsgFormat(InputStream stream)
Determines whether the specified stream has a MSG format.
stream
- The message stream.true
if the stream is represented in MSG format]; otherwise, false
.public final void setStringPropertyValue(long tag, String value)
Sets the string property value.
tag
- The property tag.value
- The property value.public final void addCustomProperty(MapiProperty property, String stringNameId)
Adds the custom property.
property
- The propertyMapiProperty
.stringNameId
- The name of propertyString
.com.aspose.ms.System.ArgumentNullException
- If property
is null.com.aspose.ms.System.ArgumentException
- If property data is null.com.aspose.ms.System.NotSupportedException
- If data type is not supported yet.public final void addCustomProperty(int type, byte[] data, String stringNameId)
Adds the custom property.
type
- Type of MapiPropertyMapiPropertyType
data
- MapiProperty data.byte
stringNameId
- The name of propertyString
.com.aspose.ms.System.ArgumentException
- If property data is null.com.aspose.ms.System.NotSupportedException
- If data type is not supported yet.public final MapiPropertyCollection getCustomProperties()
Gets collection of custom MapiProperties.
MapiPropertyCollection
.public final IMapiMessageItem toMapiMessageItem()
Convert MapiMessage to IMapiMessageItem object in dependence with MessageClass.
com.aspose.ms.System.NotSupportedException
- Thrown when MessageClass doesn't belong to IPM.Note, IPM.StickyNote,
IPM.Contact, IPM.Activity, IPM.Appointment, IPM.Schedule.meeting, IPM.Task.
public final MailMessage toMailMessage(MailConversionOptions options)
Creates an instance of MailMessage from this MapiMessage.
options
- Allows to specify additional options when converting from MapiMessage to MailMessage.public final void save(String fileName, SaveOptions options)
Saves message as a file with additional options.
fileName
- Stream into which message is saved.options
- Additional options for savingSaveOptions
.public final void save(OutputStream stream, SaveOptions options)
Saves message as a stream with additional options.
stream
- Stream into which message is saved.options
- Additional options for savingSaveOptions
.public final void saveAsTnef(OutputStream stream)
Save message in TNEF format.
stream
- The stream where a message will be saved to.public final void saveAsTnef(String fileName)
Save message in TNEF format.
fileName
- Name of the file where a message will be saved to.public final void save(String fileName)
Saves to the specified file as Msg.
fileName
- Name of the file.public final void saveAsTemplate(String fileName)
Saves to the specified file as Outlook File Template(OFT format).
fileName
- Name of the file.public final void save(OutputStream stream)
Saves to the specified stream as Msg.
stream
- The stream.public final void saveAsTemplate(OutputStream stream)
Saves to the specified stream as Outlook File Template(OFT format).
stream
- The stream.public final BounceResult checkBounced()
Checks whether this message can be treated as a bounce message.
BounceResult
.public final MapiMessage deepClone()
Creates a new object that is a copy of the current instance.
public void setProperty(MapiAttachment value, long signed, long key)
Sets the attachment.
value
- The property value.signed
- The value, that indicates that the property is signed.key
- The property tag.public void setProperty(MapiRecipient value, long signed, long key)
Sets the recipient.
value
- The property value.signed
- The value, that indicates that the property is signed.key
- The property tag.