MailMessage

MailMessage class

Inherits: Aspose::Email::IPreferredTextEncodingProvider, Aspose::Email::IMessage

Provides possibility to handle rendering of hyperlink in custom style.

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.

The following example shows how to create a new Email Message and save with SaveOptions .

var message = new MailMessage
{
 // Set subject of the message, Html body and sender information
    Subject = "New message created by Aspose.Email for .NET",
    HtmlBody = "<b>This line is in bold.</b> <br/> <br/>" +
 "<font color=blue>This line is in blue color</font>",
    From = new MailAddress("from@domain.com", "Sender Name", false)
};
 
// Add TO recipients and Add CC recipients
message.To.Add(new MailAddress("to1@domain.com", "Recipient 1", false));
message.To.Add(new MailAddress("to2@domain.com", "Recipient 2", false));
message.CC.Add(new MailAddress("cc1@domain.com", "Recipient 3", false));
message.CC.Add(new MailAddress("cc2@domain.com", "Recipient 4", false));
 
// Save message to EML, EMLX, MSG and MHTML formats
message.Save("CreateNewMailMessage_out.eml", SaveOptions.DefaultEml);
message.Save("CreateNewMailMessage_out.emlx", SaveOptions.CreateSaveOptions(MailMessageSaveType.EmlxFormat));
message.Save("CreateNewMailMessage_out.msg", SaveOptions.DefaultMsgUnicode);
message.Save("CreateNewMailMessage_out.mhtml", SaveOptions.DefaultMhtml);
' Create a new instance of MailMessage class
Dim message As MailMessage = New MailMessage()
 
' Set subject of the message, Html body and sender information
message.Subject = "New message created by Aspose.Email for .NET"
message.HtmlBody = "<b>This line is in bold.</b> <br/> <br/>" & "<font color=blue>This line is in blue color</font>"
message.From = New MailAddress("from@domain.com", "Sender Name", False)
 
' Add TO recipients and Add CC recipients
message.[To].Add(New MailAddress("to1@domain.com", "Recipient 1", False))
message.[To].Add(New MailAddress("to2@domain.com", "Recipient 2", False))
message.CC.Add(New MailAddress("cc1@domain.com", "Recipient 3", False))
message.CC.Add(New MailAddress("cc2@domain.com", "Recipient 4", False))
 
' Save message in EML, EMLX, MSG and MHTML formats
message.Save("CreateNewMailMessage_out.eml", SaveOptions.DefaultEml)
message.Save("CreateNewMailMessage_out.emlx", SaveOptions.CreateSaveOptions(MailMessageSaveType.EmlxFormat))
message.Save("CreateNewMailMessage_out.msg", SaveOptions.DefaultMsgUnicode)
message.Save("CreateNewMailMessage_out.mhtml", SaveOptions.DefaultMhtml)

Constructors

NameDescription
MailMessage (5 overloads)Initializes a new instance of the MailMessage class

Methods

NameDescription
AddAlternateViewAdd an alternate view to message
AddAttachmentAdd an attachment to message
BuildDeliveryStatusNotificationString
CheckBouncedChecks whether this message can be treated as a bounce message.
CloneClones this instance
CreateContentData
CreateDKIMContentData
CreateReadReceiptCreates the read receipt.
Dispose (2 overloads)Releases all resources used by the MailMessage
EqualsDetermines whether the specified Object is equal to the current Object.
ForceTextContentType
get_AlternateViewsGets the collection of alternate views of message
get_AttachmentsGets the collection of attachments of message
get_BccGets the address collection that contains the BCC recipients of message
get_BodyGets 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.
get_BodyEncodingGets encoding of body
get_BodyTypeGets the type of the body.
get_CategoriesGets exchange message categories
get_CCGets the address collection that contains the CC recipients
get_DateGets the date of message
get_DeliveryNotificationOptionsGets the delivery notifications
get_EpilogueGets an epilogue text. It is located after the last boundary.
get_ExtendedPropertiesGets extended properties of a message.
get_FromGets the from address
get_HeadersGets headers collection of message
get_HtmlBodyGets html body
get_IsBodyHtmlGets a value indicating whether the message body is in Html
get_IsDraftGets value that indicates whether or not a message has been sent.
get_IsEmpty
get_IsEncryptedGets a value indicating whether the message is encrypted.
get_IsRead
get_IsReadOnlyGets a value indicating whether the message is read only
get_IsSignedGets a value indicating whether the message is signed.
get_ItemIdRepresents identification information about message in a mailbox.
get_LinkedResourcesGets the collection of linked resources of message
get_ListUnsubscribeThe List-Unsubscribe field describes the command (preferably using mail) to directly unsubscribe the user(removing them from the list). For more details please see https://tools.ietf.org/html/rfc2369
get_Message
get_MessageIdGets the message id
get_OriginalIsTnefGets a value indicating whether original EML message is in TNEF format.
get_PreambleGets a preamble text. It is located before the first boundary and generally includes an explanatory note to non-MIME conformant readers.
get_PreferredTextEncodingGets preferred encoding for all text properties
get_PreserveTnefAttachmentControls TNEF attachment load/save behaviour
get_PriorityGets the priority of message
get_ReadReceiptRequested
get_ReadReceiptToGets the read receipt address.
get_ReplyToListGets the list of addresses to reply to for the mail message
get_ReversePathGets ReversePath address
get_SenderGets sender address
get_SensitivityGets the sensitivity of message
get_SubjectGets the subject line
get_SubjectEncodingGets the encoding of subject
get_SuppressBccIndicates whether Bcc header is suppressed in MIME.
get_TimeZoneOffsetGets the Coordinated Universal Time (UTC) offset for the message dates. This property defines the time zone difference, between the local time and UTC.
get_TnefAttachmentGets the tnef attachment.
get_ToGets the address collection that contains the recipients of message
get_VentLicenseThis stores the venture licensing state instead of 2 obvious fields such as string value for watermark and some value indicating license is set or not.
get_XMailerGets the X-Mailer the software that created the e-mail message
GetAlternateViewContentGets the content as a string from the specified AlternateView .
GetEmlStream
GetHashCodeReturns a hash code for object
GetHeadersAsString
GetHtmlBodyText (2 overloads)Gets the message html body as plain text. This method parses the HtmlBody property and returns plain text content ignoring the html markup.
GetHtmlView
GetLinkedResourceCountGets the count of message linked resources and alternative view linked resourced.
GetTextPlainView
ImportPopulates a T:System::Runtime::Serialization::SerializationInfo with the data needed to serialize the target object.
ImportHeaders (2 overloads)
ListAttachmentBase
Load (4 overloads)Load message from stream
LoadInternal (2 overloads)Load message from stream. NOTE!!! Call this method if you don’t need to increase customer consumption credit for Dynabic.Metered.
LoadMessageStructureLoads the message structure and search text body and html body parts’ indexes
OnConversionProgress
RecomposeTnefContentComposes 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.
Replace
Save (4 overloads)Save message as a stream
Send
set_BccSets the address collection that contains the BCC recipients of message
set_BodySets 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.
set_BodyEncodingSets encoding of body
set_CategoriesSets exchange message categories
set_CCSets the address collection that contains the CC recipients
set_DateSets the date of message
set_DeliveryNotificationOptionsSets the delivery notifications
set_EpilogueSets an epilogue text. It is located after the last boundary.
set_From (2 overloads)Sets the from address
set_HtmlBodySets html body
set_IsBodyHtmlSets a value indicating whether the message body is in Html
set_IsDraftSets value that indicates whether or not a message has been sent.
set_ItemIdRepresents identification information about message in a mailbox.
set_ListUnsubscribeThe List-Unsubscribe field describes the command (preferably using mail) to directly unsubscribe the user(removing them from the list). For more details please see https://tools.ietf.org/html/rfc2369
set_MessageIdSets the message id
set_PreambleSets a preamble text. It is located before the first boundary and generally includes an explanatory note to non-MIME conformant readers.
set_PreferredTextEncodingSets preferred encoding for all text properties
set_PreserveTnefAttachmentControls TNEF attachment load/save behaviour
set_PrioritySets the priority of message
set_ReadReceiptRequested
set_ReadReceiptTo (2 overloads)Sets the read receipt address.
set_ReplyToList (3 overloads)
set_ReversePathSets ReversePath address
set_Sender (2 overloads)Sets sender address
set_SensitivitySets the sensitivity of message
set_SubjectSets the subject line
set_SubjectEncodingSets the encoding of subject
set_SuppressBccIndicates whether Bcc header is suppressed in MIME.
set_TimeZoneOffsetSets the Coordinated Universal Time (UTC) offset for the message dates. This property defines the time zone difference, between the local time and UTC.
set_TnefAttachmentGets the tnef attachment.
set_To (3 overloads)
set_XMailerSets the X-Mailer the software that created the e-mail message
SetContent
SetHtmlBody (2 overloads)Sets html body.
SetMessageId
SetVentureLicenseAll Aspose products should implement this method. It is called by a GroupDocs product to indicate whether GroupDocs itself is licensed or not and specify a custom watermark. When GroupDocs is licensed, this document instance should behave as licensed too even if the Aspose product is not licensed.
ToStringReturns a string that represents the current object.
TryGetEncodingFromHtmlBody
ValidateMessage (2 overloads)Validate eml message for corresponding to mime specification.
Aspose::Email::Clients::Google::Commands::MessageAPI::V1::GetMessageCommand
Aspose::Email::Clients::Graph::GraphClientV1
Aspose::Email::Clients::Graph::V1::Commands::CreateMailMessageCommand
Aspose::Email::Clients::Graph::V1::Commands::SendMailMessageCommand
Aspose::Email::Clients::Graph::V1::Commands::UpdateMailMessageCommand
Aspose::Email::Clients::Imap::Commands::FetchMessageGrCommand
Aspose::Email::Clients::Imap::Commands::FetchMessagesGrCommand
Aspose::Email::Mapi::MailMessageInterpretor
Aspose::Email::Mapi::MapiMessage
attachments
body
bodyEncoding
bodyHtml
boundaries
ConversionProgressEventEvent to notify user about progress of conversion/saving.
deliveryStatusNotification
disposed
isBodyHtml
isProcessedByMboxrdStorageWriterThe property is true, if the current message is processed by a MboxrdStorageWriter. See EMAILNET-38895 and EMAILNET-39005
linkedResources
message
views