com.aspose.email

Interfaces

Classes

Enums

Exceptions

com.aspose.email

Class MailMessage

    • Constructor Detail

      • MailMessage

        public MailMessage(String from,
                   String to)

        Initializes a new instance of the MailMessage class

        Parameters:
        from - Sender address
        to - Recipient address
      • MailMessage

        public MailMessage()

        Initializes a new instance of the MailMessage class

      • MailMessage

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

        Initializes a new instance of the MailMessage class

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

        public MailMessage(MailAddress from,
                   MailAddress to)

        Initializes a new instance of the MailMessage class

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

      • getFrom

        public MailAddress getFrom()

        Gets or sets the from address

        Specified by:
        getFrom in interface IMessage
        Returns:
        A from address
      • setFrom

        public void setFrom(MailAddress value)

        Gets or sets the from address

      • getSender

        public MailAddress getSender()

        Gets or sets sender address

      • setSender

        public void setSender(MailAddress value)

        Gets or sets sender address

      • getReversePath

        public MailAddress getReversePath()

        Gets or sets ReversePath address

      • setReversePath

        public void setReversePath(MailAddress value)

        Gets or sets ReversePath address

      • getReplyToList

        public MailAddressCollection getReplyToList()

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

      • setReplyToList

        public void setReplyToList(MailAddressCollection value)

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

      • getTo

        public MailAddressCollection getTo()

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

        Specified by:
        getTo in interface IMessage
        Returns:
        A recipients
      • setTo

        public void setTo(MailAddressCollection value)

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

      • getBcc

        public MailAddressCollection getBcc()

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

        Specified by:
        getBcc in interface IMessage
        Returns:
        A BCC recipients
      • setBcc

        public void setBcc(MailAddressCollection value)

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

      • getCC

        public MailAddressCollection getCC()

        Gets or sets the address collection that contains the CC recipients

      • setCC

        public void setCC(MailAddressCollection value)

        Gets or sets the address collection that contains the CC recipients

      • getPriority

        public MailPriority getPriority()

        Gets or sets the priority of message

      • setPriority

        public void setPriority(MailPriority value)

        Gets or sets the priority of message

      • getSensitivity

        public MailSensitivity getSensitivity()

        Gets or sets the sensitivity of message

      • setSensitivity

        public void setSensitivity(MailSensitivity value)

        Gets or sets the sensitivity of message

      • getDeliveryNotificationOptions

        public int getDeliveryNotificationOptions()

        Gets or sets the delivery notifications

      • setDeliveryNotificationOptions

        public void setDeliveryNotificationOptions(int value)

        Gets or sets the delivery notifications

      • getSubject

        public String getSubject()

        Gets or sets the subject line

        Specified by:
        getSubject in interface IMessage
        Returns:
        A message subject
      • setSubject

        public void setSubject(String value)

        Gets or sets the subject line

        Specified by:
        setSubject in interface IMessage
      • getTimeZoneOffset

        public double getTimeZoneOffset()

        Gets or sets the Coordinated Universal Time (UTC) offset for the message dates. This property defines the time zone difference, between the local time and UTC.

        Returns:
        A Coordinated Universal Time offset
      • setTimeZoneOffset

        public void setTimeZoneOffset(double value)

        Gets or sets the Coordinated Universal Time (UTC) offset for the message dates. This property defines the time zone difference, between the local time and UTC.

        Parameters:
        value - A UTC offset
      • getDate

        public Date getDate()

        Gets or sets the date of message

        Specified by:
        getDate in interface IMessage
        Returns:
        A date of message
      • getLocalDate

        public Date getLocalDate()

        Gets the local date of message

        Returns:
        A local date of message
      • isLocalDate

        public boolean isLocalDate()

        Defines if date is local date

        Returns:
        true if date is local date
      • setDate

        public void setDate(Date value)

        Gets or sets the date of message

        Parameters:
        value - A date of message
      • getMessageId

        public String getMessageId()

        Gets or sets the message id

      • setMessageId

        public void setMessageId(String value)

        Gets or sets the message id

      • getXMailer

        public String getXMailer()

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

      • setXMailer

        public void setXMailer(String value)

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

      • getSubjectEncoding

        public Charset getSubjectEncoding()

        Gets or sets the encoding of subject

        Returns:
        An encoding of subject
      • setSubjectEncoding

        public void setSubjectEncoding(Charset value)

        Gets or sets the encoding of subject

        Parameters:
        value - An encoding of subject
      • getHeaders

        public HeaderCollection getHeaders()

        Gets headers collection of message

      • getHtmlBody

        public String getHtmlBody()

        Gets or sets html body

        Specified by:
        getHtmlBody in interface IMessage
        Returns:
        A html formatted message body
      • setHtmlBody

        public void setHtmlBody(String value)

        Gets or sets html body

        Specified by:
        setHtmlBody in interface IMessage
      • getBody

        public String getBody()

        Gets or sets the plain text representation of message's body.

        Specified by:
        getBody in interface IMessage
        Returns:
        A message body
      • setBody

        public void setBody(String value)

        Gets or sets the plain text representation of message's body.

        Specified by:
        setBody in interface IMessage
      • getHtmlBodyText

        public String getHtmlBodyText()

        Gets the message htmlbody as plain text.

      • getBodyEncoding

        public Charset getBodyEncoding()

        Gets or sets encoding of body

        Returns:
        An encoding of body
      • setBodyEncoding

        public void setBodyEncoding(Charset value)

        Gets or sets encoding of body

        Parameters:
        value - An encoding of body
      • isBodyHtml

        public boolean isBodyHtml()

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

      • isBodyHtml

        public void isBodyHtml(boolean value)

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

      • isSigned

        public boolean isSigned()

        Gets a value indicating whether the message is signed.

      • isEncrypted

        public boolean isEncrypted()

        Gets a value indicating whether the message is encrypted.

      • isReadOnly

        public boolean isReadOnly()

        Gets a value indicating whether the message is read only

      • isDraft

        public boolean isDraft()

        Gets or sets value that indicates whether or not a message has been sent.

      • isDraft

        public void isDraft(boolean value)

        Gets or sets value that indicates whether or not a message has been sent.

      • getLinkedResources

        public LinkedResourceCollection getLinkedResources()

        Gets the collection of linked resources of message

      • getAlternateViews

        public AlternateViewCollection getAlternateViews()

        Gets the collection of alternate views of message

      • getBodyType

        public int getBodyType()

        Gets the type of the body.

        Specified by:
        getBodyType in interface IMessage
        Returns:
        A type of the body
      • getOriginalIsTnef

        public boolean getOriginalIsTnef()

        Gets a value indicating whether original EML message is in TNEF format.

      • getCc

        public com.aspose.ms.System.Collections.Generic.IGenericCollection getCc()

        Gets CC recipients

        Specified by:
        getCc in interface IMessage
        Returns:
        A CC recipients
      • setFrom

        public void setFrom(IMailAddress value)

        Sets from address

        Specified by:
        setFrom in interface IMessage
        Parameters:
        value - A from address
      • load

        public static MailMessage load(String fileName)

        Load message from file

        Parameters:
        fileName - Message file name. The message file must be in eml or msg format.
        Returns:
        E-mail message
      • load

        public static MailMessage load(InputStream stream)

        Load message from stream

        Parameters:
        stream - Stream that represents message in eml or msg format
        Returns:
        E-mail message
      • load

        public static MailMessage load(String fileName,
                       LoadOptions options)

        Load message from file with additional options.

        Parameters:
        fileName - Source file pathString.
        options - Additional options LoadOptions.
        Returns:
        Mail messageMailMessage.
        Throws:
        com.aspose.ms.System.ArgumentNullException - If fileName is null.
      • load

        public static MailMessage load(InputStream stream,
                       LoadOptions options)

        Load message from stream with additional options.

        Parameters:
        stream - Source streamStream.
        options - Additional options LoadOptions.
        Returns:
        Mail messageMailMessage.
        Throws:
        com.aspose.ms.System.ArgumentNullException - If stream is null.
      • validateMessage

        public static EmlValidationErrorCollection validateMessage(String fileName)

        Validate eml message for corresponding to mime specification.

        Parameters:
        fileName - A file name (eml).
        Returns:
        A EmlValidationErrorCollection containing the found validation error messages.
        Throws:
        com.aspose.ms.System.ArgumentException - fileName is null or empty.
        com.aspose.ms.System.IO.FileNotFoundException - The specified fileName doesn't exist.
      • validateMessage

        public static EmlValidationErrorCollection validateMessage(InputStream stream)

        Validate eml message for corresponding to mime specification.

        Parameters:
        stream - A stream containing the message in eml format.
        Returns:
        A EmlValidationErrorCollection containing the found validation error messages.
        Throws:
        com.aspose.ms.System.ArgumentNullException - stream is null.
      • 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
      • recomposeTnefContent

        public void recomposeTnefContent()

        Composes the TNEF content. Note, that tnef attachment is composed if a message initially contained TNEF and was loaded without FileCompatibilityMode.PreserveTnefAttachments flag, That is this method doesn't create tnef message out of the regular one.

      • save

        public void save(String fileName)

        Save message as a file

        Specified by:
        save in interface IMessage
        Parameters:
        fileName - Name of a file to save message.
      • save

        public void save(String fileName,
                SaveOptions options)

        Save message as a file with additional options.

        Parameters:
        fileName - Stream into which message is saved.
        options - Additional options for savingSaveOptions.
      • save

        public void save(OutputStream stream,
                SaveOptions options)

        Save message as a stream with additional options.

        Parameters:
        stream - Stream into which message is saved.
        options - Additional options for savingSaveOptions.
      • save

        public void save(OutputStream stream)

        Save message as a stream

        Specified by:
        save in interface IMessage
        Parameters:
        stream - Stream into which message is saved
      • getReadReceiptTo

        public MailAddressCollection getReadReceiptTo()

        Gets or sets the read receipt address.

        Value: The MailAddressCollection that represents
      • setReadReceiptTo

        public void setReadReceiptTo(MailAddressCollection value)

        Gets or sets the read receipt address.

        Value: The MailAddressCollection that represents
      • createReadReceipt

        public MailMessage createReadReceipt(String from,
                                    String bodyText)

        Creates the read receipt.

        Parameters:
        from - String that represents the sender address.
        bodyText - The message body text. The default message body text will be applied if this parameter is null or empty.
        Returns:
        A newly created MailMessage that represents the read receipt.
      • 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
      • dispose

        public void dispose()

        Releases all resources used by the MailMessage

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

        public MailMessage attachSignature(byte[] certificateRawData,
                                  String certificatePassword)

        Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.

        Parameters:
        certificateRawData - X.509 certificate.
        certificatePassword - The password required to access the X.509 certificate data
        Returns:
        The signed MailMessage.
      • checkSignature

        public static boolean checkSignature(String fileName)

        Checks the signature of the specified eml file.

        Parameters:
        fileName - A file name (eml).
        Returns:
        True if signature is valid; otherwise, false.
        Throws:
        com.aspose.ms.System.ArgumentException - fileName is null or empty.
        com.aspose.ms.System.IO.FileNotFoundException - The specified fileName doesn't exist.
        com.aspose.ms.System.NotSupportedException - Signature type is not supported.
        com.aspose.ms.System.InvalidOperationException - Mail message is not signed or signature type is not specified.
      • checkSignature

        public static boolean checkSignature(InputStream stream)

        Checks the signature of the specified eml message.

        Parameters:
        stream - A stream containing the message in eml format.
        Returns:
        True if signature is valid; otherwise, false.
        Throws:
        com.aspose.ms.System.ArgumentNullException - stream is null.
        com.aspose.ms.System.NotSupportedException - Signature type is not supported.
        com.aspose.ms.System.InvalidOperationException - Mail message is not signed or signature type is not specified.
      • checkSignature

        public void checkSignature()

        Checking signature exsisting MailMessage.

        Throws:
        com.aspose.ms.System.InvalidOperationException - Throws if Mail message is not signed.
      • removeSignature

        public MailMessage removeSignature()

        Remove signature

        Returns:
        E-mail message
      • decrypt

        public MailMessage decrypt()

        Decrypts this message

        Returns:
        E-mail message
      • decrypt

        public MailMessage decrypt(byte[] certificateRawData,
                          String certificatePassword)

        Decrypts this message

        Parameters:
        certificateRawData - System.Security.Cryptography.X509Certificates.X509Certificate2
        certificatePassword - The password required to access the X.509 certificate data
        Returns:
        E-mail message
      • encrypt

        public MailMessage encrypt(byte[] certificateRawData,
                          String certificatePassword)

        Encrypts this message

        Parameters:
        certificate - X509 certificate to encrypt message
        Returns:
        Encrypted email message
      • dKIMSign

        public MailMessage dKIMSign(com.aspose.ms.System.Security.Cryptography.RSACryptoServiceProvider rsa,
                           DKIMSignatureInfo signatureInfo)

        Signs this message using DKIM (DomainKeys Identified Mail) signature.

        Parameters:
        rsa - RSA class containing private key used for signing.
        signatureInfo - DKIM signature information.
        Returns:
      • checkBounced

        public BounceResult checkBounced()

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

        Returns:
        Result of checkingBounceResult.
      • iterator

        public com.aspose.ms.System.Collections.Generic.IGenericEnumerator<MailMessage> iterator()

        Returns an enumerator that iterates through a collection.

        Specified by:
        iterator in interface com.aspose.ms.System.Collections.Generic.IGenericEnumerable<MailMessage>
        Specified by:
        iterator in interface com.aspose.ms.System.Collections.IEnumerable<MailMessage>
        Specified by:
        iterator in interface Iterable<MailMessage>
        Returns:
        An IEnumerator object that can be used to iterate through the collection.
      • dispose

        protected void dispose(boolean disposing)

        Releases unmanaged and - optionally - managed resources

        Parameters:
        disposing - true to release both managed and unmanaged resources; false to release only unmanaged resources.