---
title: "Converting email files (MSG/EML) to PDF format | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/conversion/email-to-pdf/"
md_url: "https://www.nutrient.io/guides/python/conversion/email-to-pdf.md"
last_updated: "2026-05-26T01:23:09.685Z"
description: "Convert email files (MSG and EML) to PDF using Nutrient Python SDK."
---

# Converting email files (MSG/EML) to PDF format

Convert email messages (MSG and EML) to PDF when you need long-term records for compliance, legal review, or business documentation. PDF output preserves message content in a stable format.

[Download sample](https://www.nutrient.io/downloads/samples/python/email-to-pdf.zip)

## How Nutrient supports this workflow

Nutrient Python SDK converts email files to PDF through a single API call.

You don’t need to manage:

- Email format parsing

- Rendering of headers, message body, and formatting

- Inline images and attachments

- MIME content handling

Use the SDK API to handle conversion logic in your application.

## Complete implementation

This example shows a complete email-to-PDF conversion flow.

Import the required Nutrient classes:

```python

from nutrient_sdk import Document
from nutrient_sdk import NutrientException

```

Open the email file with a Python [context manager](https://docs.python.org/3/reference/datamodel.html#context-managers). The context manager closes the document automatically:

```python

def main():
    try:
        with Document.open("input.msg") as document:

```

Export the file to PDF and handle conversion errors with `NutrientException`:

```python

            document.export_as_pdf("output.pdf")
            print("Successfully converted to output.pdf")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

## Summary

The conversion flow has two steps:

1. Open the email file.

2. Export it as PDF.

Nutrient handles email parsing and PDF rendering, so you don’t need to implement format-specific conversion logic.

You can download [this sample package](https://www.nutrient.io/downloads/samples/python/email-to-pdf.zip) to run the example locally.
---

## Related pages

- [Converting CAD files (DWG/DXF) to PDF format](/guides/python/conversion/cad-to-pdf.md)
- [Handling errors in document processing workflows](/guides/python/conversion/error-handling.md)
- [Converting a document from XLSX to PDF format](/guides/python/conversion/excel-document-to-pdf.md)
- [Converting a document from Markdown to PDF format](/guides/python/conversion/markdown-to-pdf.md)
- [Nutrient Python SDK conversion guides](/guides/python/conversion.md)
- [Converting PDF documents to HTML format for web publishing](/guides/python/conversion/pdf-to-html.md)
- [Converting PDF documents to Excel format for data analysis](/guides/python/conversion/pdf-to-excel-document.md)
- [Converting PDF documents to PDF/UA format](/guides/python/conversion/pdf-to-pdf-ua.md)
- [Converting PDF documents to image format](/guides/python/conversion/pdf-to-image.md)
- [Converting PDF documents to Markdown format](/guides/python/conversion/pdf-to-markdown.md)
- [Converting PDF documents to PDF/A format](/guides/python/conversion/pdf-to-pdf-a.md)
- [Converting a Word document to PDF while preserving comments](/guides/python/conversion/word-document-to-pdf-including-comments.md)
- [Converting PDF documents to PowerPoint presentations](/guides/python/conversion/pdf-to-powerpoint-document.md)
- [Converting a document from PDF to DOCX format](/guides/python/conversion/pdf-to-word-document.md)
- [Converting a document from DOCX to PDF/UA format](/guides/python/conversion/word-document-to-pdf-ua.md)
- [Converting a document from DOCX to PDF format](/guides/python/conversion/word-document-to-pdf.md)
- [Converting a document from PPTX to PDF format](/guides/python/conversion/powerpoint-document-to-pdf.md)

