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(boolean increaseCredit)

        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

      • 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

      • setTo

        public void setTo(MailAddressCollection value)

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

      • setBcc

        public void setBcc(MailAddressCollection value)

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

      • 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
      • setSubject

        public void setSubject(String value)

        Gets or sets the subject line

        Specified by:
        setSubject in interface IMessage
      • getTimeZoneOffset

        public final 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.

      • setTimeZoneOffset

        public final 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.

      • getDate

        public Date getDate()

        Gets or sets the date of message

        Specified by:
        getDate in interface IMessage
      • 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

      • 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

      • setSubjectEncoding

        public void setSubjectEncoding(Charset value)

        Gets or sets the encoding of subject

      • getHeaders

        public HeaderCollection getHeaders()

        Gets headers collection of message

      • 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
      • 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 final String getHtmlBodyText()

        Gets the message htmlbody as plain text.

      • getBodyEncoding

        public Charset getBodyEncoding()

        Gets or sets encoding of body

      • setBodyEncoding

        public void setBodyEncoding(Charset value)

        Gets or sets 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 final int getBodyType()

        Gets the type of the body.

        Specified by:
        getBodyType in interface IMessage
      • getOriginalIsTnef

        public boolean getOriginalIsTnef()

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

      • getCc

        public final com.aspose.ms.System.Collections.Generic.IGenericCollection<MailAddress> getCc()

        Gets CC recipients

      • setFrom

        public final 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.
      • 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 final 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.

      • getHtmlBodyText

        public String getHtmlBodyText(boolean showUrl)

        Gets the message htmlbody as plain text.

        Parameters:
        showUrl - Defines need to show URL in text.
      • getHtmlBodyText

        public String getHtmlBodyText(HyperlinkRenderingCallback hyperlinkRenderingCallback)

        Gets the message htmlbody as plain text.

        Parameters:
        hyperlinkRenderingCallback - Reference to custom method for handling rendering of hyperlink.
        Returns:
        Result string of custom handling rendering of hyperlink.
      • 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.
      • toString

        public String toString()

        Returns a string that represents the current object.

        Overrides:
        toString in class Object
        Returns:
        A string that represents the current object.
      • hashCode

        public int hashCode()

        Returns a hash code for object

        Overrides:
        hashCode in class Object
        Returns:
      • equals

        public boolean equals(Object obj)

        Determines whether the specified Object is equal to the current Object.

        Overrides:
        equals in class Object
        Parameters:
        obj - The Object to compare with the current Object.
        Returns:
        Returns a boolean indicating if the passed in object obj is Equal to this.
      • 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
      • createReadReceipt

        public final 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 final 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 String[] checkSignature()

        Checking signature exsisting MailMessage.

        Returns:
        X.509 signers certificates
        Throws:
        com.aspose.ms.System.InvalidOperationException - Throws if Mail message is not signed or signature is not verified.
      • 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 final 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.
      • unSubscribeFromEvents

        protected void unSubscribeFromEvents()