---
title: "Convert Email to HTML and Export"
canonical_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/email-to-html"
md_url: "https://www.compdf.com/guides/generation-sdk/dotnet-core/generation/email-to-html.md"
description: "ComPDF SDK Guides. In this developer's guide, all the details and how to use ComPDF for SDK Guides will be covered in depth."
---

# Convert Email to HTML and Export

Convert the email to HTML first, then read the content, export an HTML directory or write the PDF as needed. Here is an example:

```csharp
using (CEmailResult result = CEmailConverter.ConvertToHtml("/mail.eml"))
{
    if (!result.IsSuccess())
        return;

    // Get the HTML string
    string html = result.GetHtml();

    // Export an offline HTML directory: index.html, resources/ (body resources) and attachments/ (attachments)
    result.ExportHtml("/mail_html/");

    // Write the PDF from the same result; this can be called repeatedly
    result.WritePdf("/mail.pdf");
}
```

The HTML references the files under `resources/` and `attachments/` by relative paths, so the HTML string alone is not a complete offline copy. Use `ExportHtml` to export the complete directory, or set `CEmailFlags.EMAIL_INLINE_RESOURCES` to embed images and other resources as data URIs where possible.
