Skip to main content

Convert Outlook msg to PDF

Project description

Test msgtopdf Code style: black

Converts Outlook .msg files to PDF

msgtopdf is a Python 3 module to convert Outlook .msg files to PDF and extract the attachments. Unlike the majority of current modules msgtopdf maintains the formatting of HTML and RTF messages and embeds any inline images in the PDF output.

As the module uses the win32com library the host machine must have Outlook installed.

msgtopdf uses the wkhtmltopdf tool to convert the HTML message to PDF and wkhtmltopdf must be installed separately.

Currently msgtopdf extracts the message body and attachments to a new subfolder using the subject of the email as the folder name.

Usage

Module Usage

Example module usage is provided in the tests/example.py file.

Command Line Usage

The command-line option msg2pdf will convert individual files or all *.msg files in a directory.

msg2pdf --help for options.

Usage: msg2pdf [OPTIONS] PATH

msg2pdf converts Outlook email messages (msg) to pdf.

The output is a folder for each email using the email subject as the
folder name including a pdf of the email and all attachments.

Inline images are included in the email pdf.

Options:
    -f, --file       Convert an individual file PATH to pdf.
    -d, --directory  Convert all msg files in directory PATH to pdf.
    --help           Show this message and exit.

Requirements

Install the Windows binary release of wkhtmltopdf

Ensure that wkhtmltopdf command is found in your PATH.

This can be tested by entering wkhtmltopdf --version in your Command Prompt.

You should receive an output similar to the attached.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\>wkhtmltopdf --version
wkhtmltopdf 0.12.5 (with patched qt)

C:\>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msgtopdf-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

msgtopdf-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file msgtopdf-0.1.1.tar.gz.

File metadata

  • Download URL: msgtopdf-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for msgtopdf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa421ed791d12a59c91325983f6eed3c6d7f05b8e0e7fa10acf8008dd7c3d4ef
MD5 698249ac02e5f8928ae43ff4d2d2f28c
BLAKE2b-256 ef0fb4cae2be28691c1a5192b018cf4738539e83e07e59b2f1d4984a9b0c68a8

See more details on using hashes here.

File details

Details for the file msgtopdf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: msgtopdf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for msgtopdf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4b312c49386ab02648454570254f8a3d31af315998e8efec2bcff5a277b96fa
MD5 8434041a2699e5502c4c41caa9bcaae2
BLAKE2b-256 ff72e99398a9fd6045c3f29a820ce3d1e31f7c98fa68cbba909cb788aa2b782d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page