This article will enable C# developers to convert EML or MSG to other popular file formats programmatically. Aspose.Email for .NET provides classes and methods and an online email converter tool to convert EML to PNG seamlessly. You cannot open EML/MSG files without installing third-party software. So, converting EML/MSG to image file formats such as PNG, and JPG will allow you to view these files easily. Therefore, in this guide, we will go through a code snippet to build an email conversion software in C#. Before going ahead, please make sure you have source EML and MSG files to implement the functionality.
The following points will be covered in this blog post:
- Email API Integration & Installation
- EML to PNG Conversion in C#
- Convert MSG to PNG Programmatically
- Free Email Converter - Live Demo
Email API Integration & Installation
To install this enterprise-level .NET library, run the following command in the NuGet Package Manager or download the DLL file here.
Install-Package Aspose.Email
In addition to Aspose.Email for .NET, you need to install the Aspose.Words for .NET API.
Install-Package Aspose.Words
Aspose.Email for .NET comes with a complete installation guide for the developers. Moreover, the installation takes a few seconds and you can start consuming the API to convert EML to PNG or MSG to PNG.
EML to PNG Conversion in C#
Now, we can write a code sample to build an email converter tool in C# programmatically.
The following steps show how to build an email conversion software to convert EML to PNG:
- Create an object of the EmlLoadOptions class that will be used to load MailMessage from EML format.
- Set a value of the RemoveSignature property to indicate whether the signature will be removed while loading.
- Invoke the Load method of the MailMessage class to load the source EML file.
- Set the Sensitivity of the message.
- Set the Priority of the message.
- Instantiate an instance of the MemoryStream class.
- Convert EML to MHTML and save to stream by calling the Save method.
- Invoke the Position property and set the current position within the stream.
- Initialize an instance of the Document class with the MHTML stream.
- Save the document as a PNG image by calling the Save method.
The following code snippet converts EML to PNG in C#.
You can see the output in the image below:
Convert MSG to PNG Programmatically
Similarly, you can convert the MSG to PNG by making the following change in the above code snippet:
- Create an object of the MsgLoadOptions class and pass it as an argument in the Load method of the MailMessage class to load the source MSG file.
The following code sample demonstrates how to convert MSG to PNG in .NET:
Free Email Converter - Live Demo
We have learned how to develop email conversion software for C# developers. Here comes an online tool to convert EML to PNG online. It is powered by Aspose.Email. Moreover, this email converter tool is web-based and comes with a user-friendly interface and you can use this email converter on mobile phones too. Above all, it is free and you do not need to go for any subscription before using it.
Email Conversion Software - Get a Free License
You can get a free temporary license to try Aspose.Email for .NET beyond evaluation limitations.
Conclusion
We are ending this blog post here with the hope that you found this article helpful. We have gone through how to build email conversion software in C# using Aspose.Email for .NET. Further, we explored an online email converter tool to convert EML to PNG online. In addition, you may go through the documentation and the API references to look at the full stack of features.
Also, we recommend you visit the Getting Started Guide.
Finally, aspose.com is writing new blog posts. So, please stay in touch for regular updates.
Help is Available
Our support team is very vibrant and helpful. You can let us know about your questions or queries on our forum.
Frequently Asked Questions – FAQs
How do I convert an EML File to an image?
You can convert EML to PNG using Aspose.Email. This library provides support for multiple programming languages. Please visit this link for further details and a code snippet.
How do I convert an MSG file?
Try our online free email converter to convert EML/MSG to other popular file formats. For a programmatic solution, please visit this link.