If you are a .NET developer looking to add EMLX to PNG conversion features inside your applications, Aspose.Total for .NET file format manipulation APIs are the way forward. By using Aspose.Email for .NET , you can convert EMLX file format to HTML. After that, by using Aspose.Words for .NET , you can render HTML to PNG.
C# API to Convert EMLX to PNG
- Open EMLX file using MailMessage class
- Convert EMLX to HTML by using Save method
- Load HTML by using Document class
- Save the document to PNG format using Save method and set Png as SaveFormat
Get Started with .NET File Format APIs
Install from command line as nuget install Aspose.Total
or via Package Manager Console of Visual Studio with Install-Package Aspose.Total
.
Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
MailMessage message = MailMessage.Load("sourceFile.emlx");
// save EMLX as a HTML
message.Save("HtmlOutput.html", SaveOptions.DefaultHtml);
// load HTML with an instance of Document
Document document = new Document("HtmlOutput.html");
// call save method while passing SaveFormat.Png
document.Save("output.png", SaveFormat.Png);
Parse EMLX File via .NET
Before converting EMLX to PNG, if you want to make sure that you are converting the correct email, you can load EMLX document, parse it and have a look at your desired property. By using MapiMessage class of Aspose.Email for .NET API, you can get sender and recipients information. For example, you can check for a specific sender email for the conversion by using SenderName property.
var outlookMessageFile = MapiMessage.FromFile("message.emlx");
// check for SenderName
if(outlookMessageFile.SenderName == "John"){
//proceed with conversion process
}
Restrict PNG Document Editing via .NET
While saving the document from EMLX to PNG, you might need to protect your output document. Sometimes you may need to limit the ability to edit a document and only allow certain actions with it. This can be useful to prevent other people from editing sensitive and confidential information in your document. Aspose.Words for .NET API, enables you to control the way you restrict the content using the ProtectionType enumeration parameter. You can set your document to read-only by using the following lines of code.
Document document = new Document("HtmlOutput.html");
// apply document protection and set protection password
doc.Protect(ProtectionType.ReadOnly, "password");
// call save method while passing SaveFormat.Png
document.Save("output.png", SaveFormat.Png);
Explore EMLX Conversion Options with .NET
What is EMLX File Format
An EMLX file is a mail message file created by Apple Mail, a default email client for macOS. It contains the email message in MIME format, along with attachments, if any. EMLX files are typically saved in the Mail directory of a users home folder. EMLX files can be opened with Apple Mail or other email clients that support the format. They can also be opened with text editors, which can be useful for viewing the raw email data. EMLX files were introduced in Mac OS X 10.4 (Tiger). Prior to that, Apple Mail used the . EML format for saved email messages.
Read MoreWhat is PNG File Format
PNG, Portable Network Graphics, refers to a type of raster image file format that use loseless compression. This file format was created as a replacement of Graphics Interchange Format (GIF) and has no copyright limitations. One of the key features of PNG is its ability to support transparency. This means that parts of an image can be transparent, allowing it to blend seamlessly with other images or backgrounds. This is particularly useful for web design and graphics, where images often need to be overlaid on top of each other. PNG also uses lossless compression, which means that the image quality is not degraded when the file size is reduced. This is in contrast to formats such as JPEG, which use lossy compression and can result in a loss of image quality.
Read More