Free Support Forum - aspose.com

Confusion about MailMessage and MapiMessage

hello i am a bit confused about the usage and conversion between MailMessage and MapiMessage class.

Your API document says

image.png (47.8 KB)

The code example seemed working. Initially I thought it might be typo in your text but there are more than 1 typos in a same sentence? I must be wrong but how can I do the conversion?

Thanks for any help.

Regards,
Kevin

@symbioIT

For converting MailMessage to MapiMessage, please follow the code given below:

// Create a new instance of MailMessage class
MailMessage message = new MailMessage();

// Set sender information
message.From = "from@domain.com";

// Add recipients
message.To.Add("to1@domain.com");
message.To.Add("to2@domain.com");

// Set subject of the message
message.Subject = "New message created by Aspose.Email";

// Set Html body of the message
message.HtmlBody = "This is test body.";

// Create an instance of MapiMessage and load the MailMessag instance into it
MapiMessage mapiMsg = MapiMessage.FromMailMessage(message);

// Save the MapiMessage to disk
mapiMsg.Save("New-Message.msg");

MapiMessage represents an Outlook Message format document that can be parsed. Whereas 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.

Moreover, thank you for highlighting the documentation typos we will surly review this.

Thanks a lot. That helps to clarify my confusions.