# Render email messages as HTML, PDF, PNG, and JPEG files
This topic describes how to use the GroupDocs.Viewer .NET API (C#) to convert email messages to HTML, PDF, PNG, and JPEG formats.
[GroupDocs.Viewer for .NET](https://products.groupdocs.com/viewer/net) allows you to render your email messages in HTML, PDF, PNG, and JPEG formats. You do not need to use third-party email clients to view the contents of email files within your .NET application (web or desktop).
To start with the GroupDocs.Viewer API, create a [Viewer](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer) class instance. Pass an email message you want to view to the class constructor. You can load the message from a file or stream. Call one of the [Viewer.View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/view/index) method overloads to convert the loaded message to HTML, PDF, or image format. These methods allow you to render the entire message or specific pages.
{{< button style="primary" link="https://products.groupdocs.app/viewer/email" >}} {{< icon "gdoc_person" >}} View email files online {{< /button >}} {{< button style="primary" link="https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET" >}} {{< icon "gdoc_github" >}} View demos and examples on GitHub {{< /button >}}
## Supported email file formats
GroupDocs.Viewer supports the following email file formats:
* [Email Message](https://docs.fileformat.com/email/eml) (.EML)
* [Apple Mail Message](https://docs.fileformat.com/email/emlx) (.EMLX)
* [Email Mailbox File](https://docs.fileformat.com/email/mbox/) (.MBOX)
* [Outlook Message Item File](https://docs.fileformat.com/email/msg) (.MSG)
* [vCard (Virtual Contact) File](https://docs.fileformat.com/email/vcf/) (.VCF, .VCARD)
GroupDocs.Viewer can detect the email file format automatically based on information in the file header.
## Render email messages as HTML
Create an [HtmlViewOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/htmlviewoptions) class instance and pass it to the [Viewer.View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/view/index) method to convert an email message to HTML. The `HtmlViewOptions` class properties allow you to control the conversion process. For instance, you can embed all external resources in the generated HTML file, minify the output file, and exclude specific fonts. Refer to the following documentation section for details: [Rendering to HTML]({{< ref "viewer/net/developer-guide/rendering-documents/rendering-to-html/_index.md" >}}).
### Create an HTML file with embedded resources
To embed an email message in an HTML page, call the [HtmlViewOptions.ForEmbeddedResources](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/htmlviewoptions/methods/forembeddedresources/index) method and specify the output file name.
{{< tabs "render-email-to-html">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create an HTML file.
var viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html");
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create an HTML file.
Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html")
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "output.html" >}}
```text
HTML file (251 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailToHtml/output.html)
{{< /tab >}}
{{< /tabs >}}
### Create an HTML file with external resources
To save an email message to a separate folder, call the [HtmlViewOptions.ForExternalResources](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/htmlviewoptions/methods/forexternalresources/index) method and pass the following parameters:
* The output file path format
* The path format for the folder with external resources
* The resource URL format
{{< tabs "render-email-to-html-external">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Specify the HTML file name and location of external resources.
// {0} is replaced with the page number, {1} with the resource name.
var viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}");
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Specify the HTML file name and location of external resources.
' {0} is replaced with the page number, {1} with the resource name.
Dim viewOptions = HtmlViewOptions.ForExternalResources("page_{0}.html", "page_{0}/resource_{0}_{1}", "page_{0}/resource_{0}_{1}")
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "render-email-to-html-external.zip" >}}
```text
page_1.html (15 KB)
page_1/resource_1_f.ttf (54 KB)
page_1/resource_1_f1.ttf (36 KB)
page_1/resource_1_f2.ttf (45 KB)
page_1/resource_1_f3.ttf (32 KB)
page_1/resource_1_i.png (9 KB)
page_1/resource_1_s.css (3 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailToHtmlExternal/render-email-to-html-external.zip)
{{< /tab >}}
{{< /tabs >}}
External resources are placed in a separate folder.
## Render email messages as PDF
Create a [PdfViewOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfviewoptions) class instance and pass it to the [Viewer.View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/view/index) method to convert an email message to PDF. The `PdfViewOptions` class properties allow you to control the conversion process. For instance, you can protect the output PDF file, reorder its pages, and specify the quality of document images. Refer to the following documentation section for details: [Rendering to PDF]({{< ref "viewer/net/developer-guide/rendering-documents/rendering-to-pdf/_index.md" >}}).
{{< tabs "render-email-to-pdf">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create a PDF file.
var viewOptions = new PdfViewOptions("output.pdf");
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create a PDF file.
Dim viewOptions = New PdfViewOptions("output.pdf")
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "output.pdf" >}}
```text
Binary file (PDF, 102 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailToPdf/output.pdf)
{{< /tab >}}
{{< /tabs >}}
## Render email messages as PNG
Create a [PngViewOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pngviewoptions) class instance and pass it to the [Viewer.View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/view/index) method to convert an email message to PNG. Use the [PngViewOptions.Height](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pngviewoptions/properties/height) and [PngViewOptions.Width](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pngviewoptions/properties/width) properties to specify the output image size in pixels.
{{< tabs "render-email-to-png">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create a PNG image.
var viewOptions = new PngViewOptions("output_{0}.png");
// Set width and height.
viewOptions.Width = 800;
viewOptions.Height = 1000;
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create a PNG image.
Dim viewOptions = New PngViewOptions("output_{0}.png")
' Set width and height.
viewOptions.Width = 800
viewOptions.Height = 1000
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "render-email-to-png.zip" >}}
```text
output_1.png (171 KB)
output_2.png (47 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailToPng/render-email-to-png.zip)
{{< /tab >}}
{{< /tabs >}}
## Render email messages as JPEG
Create a [JpgViewOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/jpgviewoptions) class instance and pass it to the [Viewer.View](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/methods/view/index) method to convert an email message to JPEG. Use the [JpgViewOptions.Height](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/jpgviewoptions/properties/height) and [JpgViewOptions.Width](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/jpgviewoptions/properties/width) properties to specify the output image size in pixels.
{{< tabs "render-email-to-jpg">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create a JPG image.
var viewOptions = new JpgViewOptions("output_{0}.jpg");
// Set width and height.
viewOptions.Width = 800;
viewOptions.Height = 1000;
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create a JPG image.
Dim viewOptions = New JpgViewOptions("output_{0}.jpg")
' Set width and height.
viewOptions.Width = 800
viewOptions.Height = 1000
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "render-email-to-jpg.zip" >}}
```text
output_1.jpg (113 KB)
output_2.jpg (35 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailToJpg/render-email-to-jpg.zip)
{{< /tab >}}
{{< /tabs >}}
## Specify rendering options
GroupDocs.Viewer supports the [EmailOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/emailoptions) class that allows you to specify different options for rendering email messages. To access these options, use the [EmailOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/baseviewoptions/emailoptions/) property for one of the following classes (depending on the output file format):
* [HtmlViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/htmlviewoptions)
* [PdfViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pdfviewoptions)
* [PngViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pngviewoptions)
* [JpgViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/jpgviewoptions)
### Set the output page size
GroupDocs.Viewer allows you to specify page size for the output file when you convert an email message to HTML, PDF, or image format. Assign a [PageSize](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pagesize/) enumeration member to the [EmailOptions.PageSize](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/emailoptions/pagesize/) property to select one of the predefined page sizes (Letter, Ledger, A0, A1, A2, A3, or A4).
The following example specifies page size for the output PDF file:
{{< tabs "render-email-with-page-size">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create a PDF file.
var viewOptions = new PdfViewOptions("output.pdf");
// Specify the page size.
viewOptions.EmailOptions.PageSize = PageSize.A4;
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create a PDF file.
Dim viewOptions = New PdfViewOptions("output.pdf")
' Specify the page size.
viewOptions.EmailOptions.PageSize = PageSize.A4
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "output.pdf" >}}
```text
Binary file (PDF, 102 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailWithPageSize/output.pdf)
{{< /tab >}}
{{< /tabs >}}
### Rename fields in the message header
GroupDocs.Viewer allows you to change how standard fields (such as _From_, _To_, _Subject_, and so on) are displayed in the email message header.

Use the [EmailOptions.FieldTextMap](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/emailoptions/properties/fieldtextmap) property to specify custom field labels. Static fields of the [Field](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/field/) class allow you to access default email header fields, as shown in the example below.
{{< tabs "render-email-with-renamed-fields">}}
{{< tab "C#" >}}
```csharp
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create an HTML file.
var viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html");
// Specify custom field labels.
viewOptions.EmailOptions.FieldTextMap[Field.From] = "Sender";
viewOptions.EmailOptions.FieldTextMap[Field.To] = "Recipient";
viewOptions.EmailOptions.FieldTextMap[Field.Sent] = "Date";
viewOptions.EmailOptions.FieldTextMap[Field.Subject] = "Email subject";
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create an HTML file.
Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html")
' Specify custom field labels.
viewOptions.EmailOptions.FieldTextMap(Field.From) = "Sender"
viewOptions.EmailOptions.FieldTextMap(Field.[To]) = "Recipient"
viewOptions.EmailOptions.FieldTextMap(Field.Sent) = "Date"
viewOptions.EmailOptions.FieldTextMap(Field.Subject) = "Email subject"
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "output.html" >}}
```text
HTML file (252 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailWithRenamedFields/output.html)
{{< /tab >}}
{{< /tabs >}}
### Specify the date and time format and change the time zone
When rendering email messages, GroupDocs.Viewer formats date and time information in the message header based on the system's date and time settings. If you want to change the default date and time format or specify the time zone offset, use the following properties:
* [EmailOptions.DateTimeFormat](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/emailoptions/datetimeformat/)---Allows you to define a custom date and time format. See the following topics for details:
* [Standard date and time format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings)
* [Custom date and time format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings)
* [EmailOptions.TimeZoneOffset](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/emailoptions/timezoneoffset/)---Specifies the hours and minutes offset from UTC. The offset is displayed with a leading sign. A plus sign (+) indicates time ahead of UTC, and a minus sign (-) indicates time behind UTC.
{{< tabs "render-email-with-datetime-format">}}
{{< tab "C#" >}}
```csharp
using System;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...
using (var viewer = new Viewer("sample.eml"))
{
// Create an HTML file.
var viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html");
// Apply a custom format to the date in the email message header.
viewOptions.EmailOptions.DateTimeFormat = "MMMM dd, yyyy H:mm:ss zzz";
// Specify the time zone offset.
viewOptions.EmailOptions.TimeZoneOffset = new TimeSpan(-7, 0, 0);
viewer.View(viewOptions);
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports System
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...
Module Program
Sub Main(args As String())
Using viewer = New Viewer("sample.eml")
' Create an HTML file.
Dim viewOptions = HtmlViewOptions.ForEmbeddedResources("output.html")
' Apply a custom format to the date in the email message header.
viewOptions.EmailOptions.DateTimeFormat = "MMMM dd, yyyy H:mm:ss zzz"
' Specify the time zone offset.
viewOptions.EmailOptions.TimeZoneOffset = New TimeSpan(-7, 0, 0)
viewer.View(viewOptions)
End Using
End Sub
End Module
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "output.html" >}}
```text
HTML file (250 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/RenderEmailWithDatetimeFormat/output.html)
{{< /tab >}}
{{< /tabs >}}
## Get mail message metadata before rendering
Sometimes it is necessary to know some metadata of the email message, loaded to the [`Viewer`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/) class, before its actual rendering through the [`Viewer.View()`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/view/#view) method. GroupDocs.Viewer for such cases provides the [`ViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo/) class that can be obtained by calling a [`Viewer.GetViewInfo()`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/getviewinfo/#getviewinfo) method. However, this [`ViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo/) class is common for all supported document formats and has no specific properties, which are present only in the mail messages.
Starting from the version 26.1 the GroupDocs.Viewer public API has a new class [`MailMessageViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/mailmessageviewinfo/). This class is a direct inheritor of the common class [`ViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo/), so it has all its properties, but also introduce the few new ones, specific for the mail messages:
- `Sent` property of `DateTime` type — returns a date and time, stored in the mail message in its original form “as-is”, without adjusting it to the local date time and so on.
- `Subject` of `String` type — return a subject of the mail message.
- `From` of `String` type — returns a “From” email address.
To obtain a metadata of the given mail message, this mail message initially should be loaded to the [`Viewer`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/) class through its [constructor](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/viewer/#constructor_4), and then the [`Viewer.GetViewInfo()`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer/viewer/getviewinfo/#getviewinfo) method should be called. This method then returns the instance of the [`ViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/viewinfo/) class, which should be casted to the [`MailMessageViewInfo`](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.results/mailmessageviewinfo/) type. And that’s all! Source code is below:
{{< tabs "get-email-info">}}
{{< tab "C#" >}}
```csharp
using System;
using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
using GroupDocs.Viewer.Results;
// ...
using (Viewer viewer = new Viewer("sample.eml"))
{
ViewInfo generalInfo = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView());
// explicit casting
MailMessageViewInfo mailMessageInfo = (MailMessageViewInfo)generalInfo;
Console.WriteLine("From: {0}; Subject: {1}; Sent: {2}.", mailMessageInfo.From, mailMessageInfo.Subject, mailMessageInfo.Sent);
// Render to any output format if needed
viewer.View(HtmlViewOptions.ForEmbeddedResources());
}
```
{{< /tab >}}
{{< tab "VB.NET">}}
```vb
Imports System
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
Imports GroupDocs.Viewer.Results
' ...
Using viewer As New Viewer("sample.eml")
Dim generalInfo As ViewInfo = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView())
' explicit casting
Dim mailMessageInfo As MailMessageViewInfo = DirectCast(generalInfo, MailMessageViewInfo)
Console.WriteLine("From: {0}; Subject: {1}; Sent: {2}.", mailMessageInfo.From, mailMessageInfo.Subject, mailMessageInfo.Sent)
' Render to any output format if needed
viewer.View(HtmlViewOptions.ForEmbeddedResources())
End Using
```
{{< /tab >}}
{{< tab "sample.eml" >}}
{{< tab-text >}}
`sample.eml` is the sample file used in this example. Click [here](https://docs.groupdocs.com/viewer/net/_sample_files/rendering-basics/render-email-messages/sample.eml) to download it.
{{< /tab-text >}}
{{< /tab >}}
{{< tab "p_1.html" >}}
```text
HTML file (251 KB)
```
[Download full output](https://docs.groupdocs.com/viewer/net/_output_files/rendering-basics/render-email-messages/GetEmailInfo/p_1.html)
{{< /tab >}}
{{< /tabs >}}
## Email messages rendering demo
The [View EML files online](https://products.groupdocs.app/viewer/eml) app is available to test and preview rendering output for email messages and other document formats.