Free Support Forum -

Load MailMessage from MIME string


Is it possible to create a MailMessage from a string representation of an email in MIME format?



Thank you for inquiry.

MailMessage.Load() accepts string, but it would consider it as file name. You may use below method to first convert the string into stream and then load it in MailMessage.

MailMessage msg = MailMessage.Load(new MemoryStream(Encoding.UTF8.GetBytes(msgString)), MessageFormat.Eml);

Thanks, that worked.