Free Support Forum -

Getting two errors when using MapiMessage.FromMailMessage

I'm trying to create an msg file.

Getting the following two errors:

The best overloaded method match for 'Aspose.Email.Outlook.MapiMessage.FromMailMessage(Aspose.Email.Mail.MailMessage)' has some invalid arguments

Argument 1: cannot convert from 'System.Net.Mail.MailMessage' to 'Aspose.Email.Mail.MailMessage'

My code in c#:

MailMessage msg = new MailMessage();

msg.From = new MailAddress("");


msg.Subject = "this is the subject";

msg.IsBodyHtml = true;

msg.Body = "html>this is the titleThis is some text in the body.";

MapiMessage outlookMsg = MapiMessage.FromMailMessage(msg); // errors are on this line

string strMsgPath = @"C:\test.msg";



Thank you for using Aspose.Email.

It seems that the project references added to your project are mixing up as the error is raised when the project contains both System.Net.Mail.MailMessage and Aspose.Email.Mail.MailMessage. In such case, please use complete qualification identifiers such as:

Aspose.Email.Mail.MailMessage msg = new Aspose.Email.Mail.MailMessage();

I have attached a sample project here for your reference that uses the same code as you have mentioned and generates the output MSG file successfully. Please have a look at it for your reference and feel free to contact us if you have any other query. We will be glad to assist you further.

Yes, that was it.



You are welcome and please feel free to contact us if you have any other query. We will try to assist your further as soon as possible.