Class MailMessage

MailMessage class

public class MailMessage : IDisposable, IEnumerable<MailMessage>, IMessage, 
    IPreferredTextEncodingProvider, ISerializable

Constructors

NameDescription
MailMessage()Initializes a new instance of the MailMessage class
MailMessage(MailAddress, MailAddress)Initializes a new instance of the MailMessage class
MailMessage(string, string)Initializes a new instance of the MailMessage class
MailMessage(string, string, string, string)Initializes a new instance of the MailMessage class

Properties

NameDescription
virtual AlternateViews { get; }Gets the collection of alternate views of message
virtual Attachments { get; }Gets the collection of attachments of message
virtual Bcc { get; set; }Gets or sets the address collection that contains the BCC recipients of message
virtual Body { get; set; }Gets or sets the plain text representation of message’s body. If the text/plain part is present in a message, the propery returns its text data. Otherwise, property returns the text content of the HtmlBody property without html markup.
virtual BodyEncoding { get; set; }Gets or sets encoding of body
BodyType { get; }Gets the type of the body.
virtual CC { get; set; }Gets or sets the address collection that contains the CC recipients
virtual Date { get; set; }Gets or sets the date of message
virtual DeliveryNotificationOptions { get; set; }Gets or sets the delivery notifications
Epilogue { get; set; }Gets or sets an epilogue text. It is located after the last boundary.
virtual From { get; set; }Gets or sets the from address
virtual Headers { get; }Gets headers collection of message
virtual HtmlBody { get; set; }Gets or sets html body
virtual IsBodyHtml { get; set; }Gets or sets a value indicating whether the message body is in Html
virtual IsDraft { get; set; }Gets or sets value that indicates whether or not a message has been sent.
virtual IsEncrypted { get; }Gets a value indicating whether the message is encrypted.
virtual IsReadOnly { get; }Gets a value indicating whether the message is read only
virtual IsSigned { get; }Gets a value indicating whether the message is signed.
virtual ItemId { get; }Represents identification information about message in a mailbox.
virtual LinkedResources { get; }Gets the collection of linked resources of message
virtual MessageId { get; set; }Gets or sets the message id
virtual OriginalIsTnef { get; }Gets a value indicating whether original EML message is in TNEF format.
Preamble { get; set; }Gets or sets a preamble text. It is located before the first boundary and generally includes an explanatory note to non-MIME conformant readers.
PreferredTextEncoding { get; set; }Gets or sets preferred encoding for all text properties
virtual Priority { get; set; }Gets or sets the priority of message
ReadReceiptTo { get; set; }Gets or sets the read receipt address.
virtual ReplyToList { get; set; }Gets or sets the list of addresses to reply to for the mail message
virtual ReversePath { get; set; }Gets or sets ReversePath address
virtual Sender { get; set; }Gets or sets sender address
virtual Sensitivity { get; set; }Gets or sets the sensitivity of message
virtual Subject { get; set; }Gets or sets the subject line
virtual SubjectEncoding { get; set; }Gets or sets the encoding of subject
TimeZoneOffset { get; set; }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.
virtual To { get; set; }Gets or sets the address collection that contains the recipients of message
virtual XMailer { get; set; }Gets or sets the X-Mailer the software that created the e-mail message

Methods

NameDescription
static Load(Stream)Load message from stream
static Load(string)Load message from file
static Load(Stream, LoadOptions)Load message from stream with additional options.
static Load(string, LoadOptions)Load message from file with additional options.
virtual AddAlternateView(AlternateView)Add an alternate view to message
virtual AddAttachment(Attachment)Add an attachment to message
virtual AttachSignature(CmsSigner)Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.
virtual AttachSignature(X509Certificate2)Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.
virtual AttachSignature(CmsSigner, bool)Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.
virtual AttachSignature(X509Certificate2, bool)Creates a signed message. Creates a read-only copy of the specified MailMessage and adds a digital signature to it.
virtual CheckBounced()Checks whether this message can be treated as a bounce message.
virtual CheckSignature()Checking signature exsisting MailMessage.
virtual Clone()Clones this instance
CreateReadReceipt(string, string)Creates the read receipt.
virtual Decrypt()Decrypts this message
virtual Decrypt(X509Certificate2)Decrypts this message
Dispose()Releases all resources used by the MailMessage
virtual DKIMSign(RSACryptoServiceProvider, DKIMSignatureInfo)Signs this message using DKIM (DomainKeys Identified Mail) signature.
virtual Encrypt(X509Certificate2)Encrypts this message
virtual Encrypt(X509Certificate2[])Encrypts this message
override Equals(object)Determines whether the specified Object is equal to the current Object.
GetAlternateViewContent(string)Gets the content as a string from the specified AlternateView.
GetEnumerator()Returns an enumerator that iterates through a collection.
override GetHashCode()Returns a hash code for object
virtual GetHtmlBodyText(bool)Gets the message html body as plain text. This method parses the HtmlBody property and returns plain text content ignoring the html markup.
virtual GetHtmlBodyText(HyperlinkRenderingCallback)Gets the message htmlbody as plain text.
virtual GetObjectData(SerializationInfo, StreamingContext)Populates a SerializationInfo with the data needed to serialize the target object.
virtual Import(Stream)Imports message from stream
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.
virtual RemoveSignature()Remove signature
virtual Save(Stream)Save message as a stream
virtual Save(string)Save message as a file
virtual Save(Stream, SaveOptions)Save message as a stream with additional options.
virtual Save(string, SaveOptions)Save message as a file with additional options.
virtual SetHtmlBody(string, bool)Sets html body.
override ToString()Returns a string that represents the current object.
static CheckSignature(Stream)Checks the signature of the specified eml message.
static CheckSignature(string)Checks the signature of the specified eml file.

See Also