Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active November 1, 2025 07:49
Show Gist options
  • Save aspose-com-kb/8ded94f3929ac5f17a12f226fc922487 to your computer and use it in GitHub Desktop.
Save aspose-com-kb/8ded94f3929ac5f17a12f226fc922487 to your computer and use it in GitHub Desktop.
Convert EML to JPG in C#. For details: https://kb.aspose.com/email/net/convert-eml-to-jpg-in-csharp/
// Initialize an object of the EmlLoadOptions class.
Aspose.Email.EmlLoadOptions EmlLoadOptions = new Aspose.Email.EmlLoadOptions();
// Call the Load method of the MailMessage class to load the source eml file.
Aspose.Email.MailMessage Mailmsg = Aspose.Email.MailMessage.Load("input.eml", EmlLoadOptions);
// Create an instance of the MemoryStream class.
MemoryStream msgStream = new MemoryStream();
// Call the Save method to convert EML to MHTML and save to stream.
Mailmsg.Save(msgStream, Aspose.Email.SaveOptions.DefaultMhtml);
// Access the Position property and set the current position within the stream.
msgStream.Position = 0;
// Instantiate an instance of the Document class with the MHTML stream.
Aspose.Words.Document msgDocument = new Aspose.Words.Document(msgStream);
// Save the document as JPG image by calling the Save method.
msgDocument.Save("output.jpg", Aspose.Words.SaveFormat.Jpeg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment