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, propertyStream, recipients, subStorages
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(MapiProperty property,
String stringNameId)
Adds the custom property.
|
BounceResult |
checkBounced()
Checks whether this message can be treated as a bounce message.
|
com.aspose.email.IMapiNode |
createMapiNode(String tag)
Creates the mapi node.
|
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.
|
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.
|
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 |
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 |
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 |
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 |
setNamedPropertyMapping(MapiNamedPropertyMappingStorage value)
Sets the named property mapping.
|
void |
setProperty(long value,
long signed,
long tag)
Sets the property.
|
void |
setProperty(MapiAttachment value,
long signed,
long tag)
Sets the attachment.
|
void |
setProperty(MapiProperty value,
long signed,
long tag)
Sets the property.
|
void |
setProperty(MapiPropertyStream value,
long signed,
long tag)
Sets the property stream.
|
void |
setProperty(MapiRecipient value,
long signed,
long tag)
Sets the recipient.
|
void |
setPropertySet(MapiProperty value,
long signed,
long tag)
Sets the property set.
|
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, getBody, getBodyHtml, getBodyRtf, getBodyType, getCategories, getCompanies, getMessageClass, getMileage, getNamedProperties, getNamedPropertyMapping, getPropertyStream, getRecipients, getSensitivity, getSubject, getSubjectPrefix, getSubStorages, initNamedPropertyMappingStorage, removeProperty, setBilling, setBody, setBodyContent, setBodyRtf, setCategories, setCompanies, setMessageClass, setMessageFlags, setMileage, setProperty, setProperty, setRecipients, setSensitivity, setsIMapiMessageItemMembers, setSubject, updateStorage, updateStorage
getCodePage, getMyProperties, getProperties, getPropertyBoolean, getPropertyBytes, getPropertyDateTime, getPropertyInt32, getPropertyLong, getPropertyShort, getPropertyString, getPropertyString, isStoreUnicodeOk, 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 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 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 String getNormalizedSubject()
Gets normalized subject of the message.
Value: The string that represents normalized subject.public 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 String getDisplayNamePrefix()
Gets a prefix of the display name.
Value: The string that represents display name prefix.public String getDisplayName()
Gets the display name for the message.
Value: The string that represents display name.public 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 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 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 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 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 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 String getSenderAddressType()
Gets the message sender's e-mail address type.
Value: The string that represents sender address type.public String getSenderName()
Gets or sets the message sender's display name.
Value: The the string that represents sender name.public void setSenderName(String value)
Gets or sets the message sender's display name.
Value: The the string that represents sender name.public String getTransportMessageHeaders()
Gets the transport-specific message envelope information.
Value: The string that represents transport message headers.public String getInternetMessageId()
Gets the message id of the message.
Value: The string that represents internet message id.public String getConversationTopic()
Gets the topic of the first message in a conversation thread.
Value: The string that represens conversation topic.public 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 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 String getSentRepresentingAddressType()
Gets the address type for the messaging user represented by the sender.
Value: The string that represents sent representing address type.public 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 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 Date getClientSubmitTime()
Gets or sets the date and time the message sender submitted a message.
Value: The DateTime that represents client submit time.public 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 Date getDeliveryTime()
Gets or sets the date and time a message was delivered.
Value: The DateTime that represents delivery time.public void setDeliveryTime(Date value)
Gets or sets the date and time a message was delivered.
Value: The DateTime that represents delivery time.public HeaderCollection getHeaders()
Gets the transport message headers
public long getFlags()
Gets the message flags.
Value: The message flags.public 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 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 int getMessageFormat()
Gets the outlook message format.
Value: The outlook message format.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 void setStringPropertyValue(long tag, String value)
Sets the string property value.
tag
- The property tag.value
- The property value.public void addCustomProperty(MapiProperty property, String stringNameId)
Adds the custom property.
property
- The propertyMapiProperty
.stringNameId
- The name of propertySystem.String
.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 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 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 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 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 void saveAsTnef(OutputStream stream)
Save message in TNEF format.
stream
- The stream where a message will be saved to.public void saveAsTnef(String fileName)
Save message in TNEF format.
fileName
- Name of the file where a message will be saved to.public void save(String fileName)
Saves to the specified file as Msg.
fileName
- Name of the file.public void saveAsTemplate(String fileName)
Saves to the specified file as Outlook File Template(OFT format).
fileName
- Name of the file.public void save(OutputStream stream)
Saves to the specified stream as Msg.
stream
- The stream.public void saveAsTemplate(OutputStream stream)
Saves to the specified stream as Outlook File Template(OFT format).
stream
- The stream.public BounceResult checkBounced()
Checks whether this message can be treated as a bounce message.
BounceResult
.public com.aspose.email.IMapiNode createMapiNode(String tag)
Creates the mapi node.
createMapiNode
in class MapiPropertyContainer
tag
- The property tag.public MapiMessage deepClone()
Creates a new object that is a copy of the current instance.
public void setProperty(MapiAttachment value, long signed, long tag)
Sets the attachment.
setProperty
in class MapiPropertyContainer
value
- The property value.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setProperty(MapiRecipient value, long signed, long tag)
Sets the recipient.
setProperty
in class MapiPropertyContainer
value
- The property value.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setProperty(long value, long signed, long tag)
Sets the property.
setProperty
in class MapiPropertyContainer
value
- The property value.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setPropertySet(MapiProperty value, long signed, long tag)
Sets the property set.
setPropertySet
in class MapiPropertyContainer
value
- The MapiPropery.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setProperty(MapiPropertyStream value, long signed, long tag)
Sets the property stream.
setProperty
in class MapiPropertyContainer
value
- The property stream.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setProperty(MapiProperty value, long signed, long tag)
Sets the property.
setProperty
in class MapiPropertyContainer
value
- The MapiProperty.signed
- The value, that indicates that the property is signed.tag
- The property tag.public void setNamedPropertyMapping(MapiNamedPropertyMappingStorage value)
Sets the named property mapping.
setNamedPropertyMapping
in class MapiMessageItemBase
value
- The MapiNamedPropertyMappingStorage.Copyright (c) 2008-2017 Aspose Pty Ltd. All Rights Reserved.