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

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:

from nutrient_sdk import Document
from nutrient_sdk import NutrientException

Open the email file with a Python context manager(opens in a new tab). The context manager closes the document automatically:

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

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

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 to run the example locally.