Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert EML & MSG Email Messages to PDF in Python
# Programmatically Convert EML file to PDF in Python using GroupDocs.Conversion Cloud API
configuration = groupdocs_conversion_cloud.Configuration("<< CLIENT_ID >>", "<< CLIENT_SECRET >>")
configuration.api_base_url = "https://api.groupdocs.cloud"
# Create API instances
apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(configuration)
# Conversion settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.file_path = "filepath/email.eml"
settings.format = "pdf"
# Load Options
loadOptions = groupdocs_conversion_cloud.EmailLoadOptions()
## Set different fields as visible or hidden
loadOptions.display_cc_email_address = False
loadOptions.display_bcc_email_address = False
settings.load_options = loadOptions
settings.output_path = "filepath/folder"
# Convert to PDF according to settings
result = apiInstance.convert_document(groupdocs_conversion_cloud.ConvertDocumentRequest(settings))
# Convert MSG Email file to PDF in Python using GroupDocs.Conversion Cloud API
configuration = groupdocs_conversion_cloud.Configuration("<< CLIENT_ID >>", "<< CLIENT_SECRET >>")
configuration.api_base_url = "https://api.groupdocs.cloud"
# Create API instances
apiInstance = groupdocs_conversion_cloud.ConvertApi.from_config(configuration)
# Conversion settings
settings = groupdocs_conversion_cloud.ConvertSettings()
settings.file_path = "filepath/email.msg"
settings.format = "pdf"
# Load Options
loadOptions = groupdocs_conversion_cloud.EmailLoadOptions()
## Set different fields as visible or hidden
loadOptions.display_header = True
loadOptions.display_from_email_address = True
loadOptions.display_to_email_address = False
loadOptions.display_email_address = True
loadOptions.display_cc_email_address = True
loadOptions.display_bcc_email_address = True
settings.load_options = loadOptions
settings.output_path = "filepath/folder"
# Convert to PDF according to settings
result = apiInstance.convert_document(groupdocs_conversion_cloud.ConvertDocumentRequest(settings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment