com.aspose.network
Class MailMessage

java.lang.Object
  extended by com.aspose.network.MailMessage
All Implemented Interfaces:
com.aspose.ms.System.IDisposable, IPreferredTextEncodingProvider, Iterable<MailMessage>

public class MailMessage
extends Object
implements com.aspose.ms.System.IDisposable, IPreferredTextEncodingProvider, Iterable<MailMessage>

Represents an e-mail message. It allows to access message properties, ex. subject, body, sender and recipients addreses, etc. Also it can be sent and delivered by means of supported mail protocols.


Constructor Summary
MailMessage()
           Constructor
MailMessage(MailAddress from, MailAddress to)
           Constructor
MailMessage(String from, String to)
           Constructor
MailMessage(String from, String to, String subject, String body)
           Constructor
 
Method Summary
 void addAlternateView(AlternateView view)
           Add an alternate view to message
 void addAttachment(Attachment attachment)
           Add an attachment to message
 void AddCalendar(com.aspose.network.CalendarObject calendar)
          Deprecated. Please use Appoinment Class.
 MailMessage deepClone()
           Clones this instance
 void dispose()
           Releases all resources used by the MailMessage
 AlternateViewCollection getAlternateViews()
           Gets the collection of alternate views of message
 AttachmentCollection getAttachments()
           Gets the collection of attachments of message
 MailAddressCollection getBcc()
           Gets or sets the address collection that contains the BCC recipients of message
 String getBody()
           Gets or sets the message body
 Charset getBodyEncoding()
           
 MailAddressCollection getCC()
           Gets or sets the address collection that contains the CC recipients
 Date getDate()
           
 int getDeliveryNotificationOptions()
           Gets or sets the delivery notifications
 MailAddress getFrom()
           Gets or sets the from address
 HeaderCollection getHeaders()
           Gets headers collection of message
 String getHtmlBody()
           Gets or sets html body
 LinkedResourceCollection getLinkedResources()
           Gets the collection of linked resources of message
 String getMessageId()
           Gets or sets the message id
 Charset getPreferredTextEncoding()
           
 com.aspose.ms.System.Text.Encoding getPreferredTextEncodingInternal()
           Gets or sets preferred encoding for all text properties
 boolean getPreserveOriginalDates()
           Gets or sets value that defines whether it is necessary to generate new saving and modification dates when saving a message
 int getPriority()
           Gets or sets the priority of message
 MailAddress getReplyTo()
          Deprecated. 
 MailAddressCollection getReplyToList()
           Gets or sets the list of addresses to reply to for the mail message
 MailAddress getSender()
           Get or sets sender address
 int getSensitivity()
           Gets or sets the sensitivity of message
 String getSubject()
           Gets or sets the subject line
 Charset getSubjectEncoding()
           
 String getTextBody()
           Gets or sets plain text body
 MailAddressCollection getTo()
           Gets or sets the address collection that contains the recipients of message
 boolean getWriteHeaderToMht()
           Gets or sets a value indicating whether header information should be written if message is being saved in mht format.
 boolean getWriteOutlineAttachmentsToMht()
           Gets or sets a value indicating whether outline attachments should be written if message is being saved in mht format.
 String getXMailer()
           Gets or sets the X-Mailer the software that created the e-mail message
 void importMessage(InputStream stream)
           Imports message from stream
 boolean isBodyHtml()
           Gets or sets a value indicating whether the message body is in Html
 void isBodyHtml(boolean value)
           
 boolean isReadOnly()
           Gets a value indicating whether the message is read only
 boolean isSigned()
           Gets or sets a value indicating whether the message is signed
 Iterator<MailMessage> iterator()
           
static MailMessage load(InputStream stream)
           Load message from stream
static MailMessage load(InputStream stream, int mode)
           Load message from stream
static MailMessage load(InputStream stream, MessageFormat format)
           Load message from stream
static MailMessage load(String fileName)
           Load message from file
static MailMessage load(String fileName, int mode)
           Load message from file
static MailMessage load(String fileName, MessageFormat format)
           Load message from stream
 void save(OutputStream stream)
           Save message as a stream
 void save(OutputStream stream, int mode)
           Save message as a stream
 void save(OutputStream stream, MailMessageSaveType savetype)
           Message saving into a stream in one of the supported formats
 void save(OutputStream stream, MessageFormat format)
           Message saving as a stream in one of the supported formats
 void save(String fileName)
           Save message as a file
 void save(String fileName, int mode)
           Save message as a file
 void save(String fileName, MailMessageSaveType savetype)
           Message saving into a file into one of the supported formats
 void save(String fileName, MessageFormat format)
           Message saving into a file into one of the supported formats
 void setBcc(MailAddressCollection value)
           
 void setBody(String value)
           
 void setBodyEncoding(Charset value)
           
 void setCC(MailAddressCollection value)
           
 void setDate(Date value)
           
 void setDeliveryNotificationOptions(int value)
           
 void setFrom(MailAddress value)
           
 void setHtmlBody(String value)
           
 void setMessageId(String value)
           
 void setPreferredTextEncoding(Charset value)
           
 void setPreferredTextEncodingInternal(com.aspose.ms.System.Text.Encoding value)
           
 void setPreserveOriginalDates(boolean value)
           
 void setPriority(int value)
           
 void setReplyTo(MailAddress value)
          Deprecated. 
 void setReplyToList(MailAddressCollection value)
           
 void setSender(MailAddress value)
           
 void setSensitivity(int value)
           
 void setSubject(String value)
           
 void setSubjectEncoding(Charset value)
           
 void setTextBody(String value)
           
 void setTo(MailAddressCollection value)
           
 void setWriteHeaderToMht(boolean value)
           
 void setWriteOutlineAttachmentsToMht(boolean value)
           
 void setXMailer(String value)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailMessage

public MailMessage(String from,
                   String to)

Constructor

Parameters:
from - Sender address
to - Recipient address

MailMessage

public MailMessage()

Constructor


MailMessage

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

Constructor

Parameters:
from - Sender address
to - Recipient address
subject - Message subject
body - Message body

MailMessage

public MailMessage(MailAddress from,
                   MailAddress to)

Constructor

Parameters:
from - Sender address
to - Recipient address
Method Detail

getPreferredTextEncodingInternal

public com.aspose.ms.System.Text.Encoding getPreferredTextEncodingInternal()

Gets or sets preferred encoding for all text properties


getPreferredTextEncoding

public Charset getPreferredTextEncoding()
Specified by:
getPreferredTextEncoding in interface IPreferredTextEncodingProvider

setPreferredTextEncodingInternal

public void setPreferredTextEncodingInternal(com.aspose.ms.System.Text.Encoding value)

setPreferredTextEncoding

public void setPreferredTextEncoding(Charset value)
Specified by:
setPreferredTextEncoding in interface IPreferredTextEncodingProvider

getFrom

public MailAddress getFrom()

Gets or sets the from address


setFrom

public void setFrom(MailAddress value)

getSender

public MailAddress getSender()

Get or sets sender address


setSender

public void setSender(MailAddress value)

getReplyTo

@Deprecated
public MailAddress getReplyTo()
Deprecated. 

Gets or sets the ReplyTo address


setReplyTo

@Deprecated
public void setReplyTo(MailAddress value)
Deprecated. 


getReplyToList

public MailAddressCollection getReplyToList()

Gets or sets the list of addresses to reply to for the mail message


setReplyToList

public void setReplyToList(MailAddressCollection value)

getTo

public MailAddressCollection getTo()

Gets or sets the address collection that contains the recipients of message


setTo

public void setTo(MailAddressCollection value)

getBcc

public MailAddressCollection getBcc()

Gets or sets the address collection that contains the BCC recipients of message


setBcc

public void setBcc(MailAddressCollection value)

getCC

public MailAddressCollection getCC()

Gets or sets the address collection that contains the CC recipients


setCC

public void setCC(MailAddressCollection value)

getPriority

public int getPriority()

Gets or sets the priority of message


setPriority

public void setPriority(int value)

getSensitivity

public int getSensitivity()

Gets or sets the sensitivity of message


setSensitivity

public void setSensitivity(int value)

getDeliveryNotificationOptions

public int getDeliveryNotificationOptions()

Gets or sets the delivery notifications


setDeliveryNotificationOptions

public void setDeliveryNotificationOptions(int value)

getSubject

public String getSubject()

Gets or sets the subject line


setSubject

public void setSubject(String value)

getDate

public Date getDate()

setDate

public void setDate(Date value)

getMessageId

public String getMessageId()

Gets or sets the message id


setMessageId

public void setMessageId(String value)

getXMailer

public String getXMailer()

Gets or sets the X-Mailer the software that created the e-mail message


setXMailer

public void setXMailer(String value)

getSubjectEncoding

public Charset getSubjectEncoding()

setSubjectEncoding

public void setSubjectEncoding(Charset value)

getHeaders

public HeaderCollection getHeaders()

Gets headers collection of message


getTextBody

public String getTextBody()

Gets or sets plain text body


setTextBody

public void setTextBody(String value)

getHtmlBody

public String getHtmlBody()

Gets or sets html body


setHtmlBody

public void setHtmlBody(String value)

getBody

public String getBody()

Gets or sets the message body


setBody

public void setBody(String value)

getBodyEncoding

public Charset getBodyEncoding()

setBodyEncoding

public void setBodyEncoding(Charset value)

isBodyHtml

public boolean isBodyHtml()

Gets or sets a value indicating whether the message body is in Html


isBodyHtml

public void isBodyHtml(boolean value)

isSigned

public boolean isSigned()

Gets or sets a value indicating whether the message is signed


isReadOnly

public boolean isReadOnly()

Gets a value indicating whether the message is read only


getPreserveOriginalDates

public boolean getPreserveOriginalDates()

Gets or sets value that defines whether it is necessary to generate new saving and modification dates when saving a message


setPreserveOriginalDates

public void setPreserveOriginalDates(boolean value)

getAttachments

public AttachmentCollection getAttachments()

Gets the collection of attachments of message


getLinkedResources

public LinkedResourceCollection getLinkedResources()

Gets the collection of linked resources of message


getAlternateViews

public AlternateViewCollection getAlternateViews()

Gets the collection of alternate views of message


getWriteHeaderToMht

public boolean getWriteHeaderToMht()

Gets or sets a value indicating whether header information should be written if message is being saved in mht format. Default value is true.

Value: true if header information should be written; otherwise, false.


setWriteHeaderToMht

public void setWriteHeaderToMht(boolean value)

getWriteOutlineAttachmentsToMht

public boolean getWriteOutlineAttachmentsToMht()

Gets or sets a value indicating whether outline attachments should be written if message is being saved in mht format. Default value is true.

Value: true if outline attachments should be written; otherwise, false.


setWriteOutlineAttachmentsToMht

public void setWriteOutlineAttachmentsToMht(boolean value)

load

public static MailMessage load(String fileName)

Load message from file

Parameters:
fileName - Message file name (.eml)
Returns:
E-mail message

load

public static MailMessage load(InputStream stream)

Load message from stream

Parameters:
stream - Stream that represents message in .eml format
Returns:
E-mail message

load

public static MailMessage load(String fileName,
                               int mode)

Load message from file

Parameters:
fileName - Message file name (.eml)
mode - FileCompatibilityMode that defines inner conversions that are necessarily to be done


If a flag FileCompatibilityMode.PreserveTnefAttachments is set, it means that TNEF attachment shouldn't be decoded if present. If a flag FileCompatibilityMode.AllowCROnly is set, it means that line separators will be replaced by CRLF.

Returns:
E-mail message

load

public static MailMessage load(InputStream stream,
                               int mode)

Load message from stream

Parameters:
stream - Stream that represents message in .eml format
mode - FileCompatibilityMode that defines inner conversions that are necessarily to be done


If a flag FileCompatibilityMode.PreserveTnefAttachments is set, it means that TNEF attachment shouldn't be decoded if present. If a flag FileCompatibilityMode.AllowCROnly is set, it means that line separators will be replaced by CRLF.

Returns:
E-mail message
Throws:
ArgumentNullException - stream is null.

load

public static MailMessage load(InputStream stream,
                               MessageFormat format)

Load message from stream

Parameters:
stream - Stream that represents message in one of the supported formats
format - Message format represented in stream
Returns:
E-mail message
Throws:
ArgumentNullException - If stream is null.
FormatNotSupportedException - If format is not supported.

load

public static MailMessage load(String fileName,
                               MessageFormat format)

Load message from stream

Parameters:
fileName - Message file name. File must be in one of the suported formats
format - Message file format
Returns:
E-mail message
Throws:
ArgumentNullException - If fileName is null.
FormatNotSupportedException - If format is not supported.

importMessage

public void importMessage(InputStream stream)

Imports message from stream

Parameters:
stream - System.IO.Stream

deepClone

public MailMessage deepClone()

Clones this instance

Returns:
MailMessage that is a copy of the current instance

save

public void save(String fileName,
                 int mode)

Save message as a file

Parameters:
fileName - Name of the file
mode - FileCompatibilityMode that defines inner conversions that are necessarily to be done


A message is saved in eml format. If a flag FileCompatibilityMode.PreserveTnefAttachments is set, it means that TNEF attachment should be preserved. Note, that now tnef attachment is saved when being loaded a message contains tnef, that is the FileCompatibilityMode.PreserveTnefAttachments flag doesn't allow to create tnef message out of an regular one.


save

public void save(OutputStream stream,
                 int mode)

Save message as a stream

Parameters:
stream - The stream into which message is saved
mode - FileCompatibilityMode that defines inner conversions that are necessarily to be done


A message is saved in eml format. If a flag FileCompatibilityMode.PreserveTnefAttachments is set, it means that TNEF attachment should be preserved. Note, that now tnef attachment is saved when being loaded a message contains tnef, that is the FileCompatibilityMode.PreserveTnefAttachments flag doesn't allow to create tnef message out of an regular one.


save

public void save(String fileName)

Save message as a file

Parameters:
fileName - File name

save

public void save(OutputStream stream)

Save message as a stream

Parameters:
stream - Stream into which message is saved

save

public void save(OutputStream stream,
                 MessageFormat format)

Message saving as a stream in one of the supported formats

Parameters:
stream - Stream into which message is saved
format - Format into which m�ssage is saved

save

public void save(OutputStream stream,
                 MailMessageSaveType savetype)

Message saving into a stream in one of the supported formats

Parameters:
stream - Stream into which message is saved
savetype - Format into which message is saved

save

public void save(String fileName,
                 MailMessageSaveType savetype)

Message saving into a file into one of the supported formats

Parameters:
fileName - Full file name
savetype - Format into which message is saved

save

public void save(String fileName,
                 MessageFormat format)

Message saving into a file into one of the supported formats

Parameters:
fileName - Full file name
format - Format into which message is saved

addAlternateView

public void addAlternateView(AlternateView view)

Add an alternate view to message

Parameters:
view - Alternate view for adding

addAttachment

public void addAttachment(Attachment attachment)

Add an attachment to message

Parameters:
attachment - Attachment for adding

AddCalendar

@Deprecated
public void AddCalendar(com.aspose.network.CalendarObject calendar)
Deprecated. Please use Appoinment Class.

Parameters:
calendar -

dispose

public void dispose()

Releases all resources used by the MailMessage

Specified by:
dispose in interface com.aspose.ms.System.IDisposable

iterator

public Iterator<MailMessage> iterator()
Specified by:
iterator in interface Iterable<MailMessage>


Copyright (c) 2002-2011 Aspose Pty Ltd. All Rights Reserved.