{"id":16535965,"url":"https://github.com/algebra-fun/docx2msg","last_synced_at":"2026-01-19T22:01:36.383Z","repository":{"id":224168725,"uuid":"762557086","full_name":"Algebra-FUN/docx2msg","owner":"Algebra-FUN","description":"Converts a docx to an Outlook Mail-Item with few lines of code.","archived":false,"fork":false,"pushed_at":"2024-03-02T06:48:01.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-27T19:09:11.460Z","etag":null,"topics":["converter","docx","email","msg","outlook","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Algebra-FUN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-24T03:38:02.000Z","updated_at":"2024-12-05T09:56:03.000Z","dependencies_parsed_at":"2024-03-02T07:33:42.190Z","dependency_job_id":null,"html_url":"https://github.com/Algebra-FUN/docx2msg","commit_stats":null,"previous_names":["algebra-fun/docx2msg"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Algebra-FUN/docx2msg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algebra-FUN%2Fdocx2msg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algebra-FUN%2Fdocx2msg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algebra-FUN%2Fdocx2msg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algebra-FUN%2Fdocx2msg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Algebra-FUN","download_url":"https://codeload.github.com/Algebra-FUN/docx2msg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Algebra-FUN%2Fdocx2msg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28587059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T20:45:59.482Z","status":"ssl_error","status_checked_at":"2026-01-19T20:45:41.500Z","response_time":67,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["converter","docx","email","msg","outlook","python"],"created_at":"2024-10-11T18:29:21.755Z","updated_at":"2026-01-19T22:01:36.366Z","avatar_url":"https://github.com/Algebra-FUN.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# docx2msg\r\n\r\nConverts a docx to an Outlook Mail-Item with few lines of code.\r\n\r\n[![PyPI](https://img.shields.io/pypi/v/docx2msg)](https://pypi.org/project/docx2msg/)\r\n[![PyPI - License](https://img.shields.io/pypi/l/docx2msg)](https://pypi.org/project/docx2msg/)\r\n\r\n## Description\r\n\r\n`docx2msg` is a python package that allows you to convert Microsoft Word .docx files to Outlook Mail-Item and .msg files. It provides a simple and efficient way to automate the conversion process, making it easier to automate with outlook email in your workflows.\r\n\r\n## Features\r\n\r\n- Convert a docx to an Outlook Mail-Item just using Word and Outlook Application without any third-party library.\r\n- Set mail properties from the header of the docx in YAML format.\r\n- Able to use docx-template to render the docx body and set mail properties dynamically.\r\n\r\n## Requirements\r\n\r\n- OS: Windows\r\n- Application: Microsoft Word, Microsoft Outlook\r\n- Python: 3.8+\r\n- Python Packages: pywin32, python-docx, docx-template, pyyaml\r\n\r\n## Installation\r\n\r\n```shell\r\npip install docx2msg\r\n```\r\n\r\n## User Guide\r\n\r\n### Quickstart\r\n\r\n\u003e The example docx file are coming soon...\r\n\r\n1. Edit the body of the docx file (which will be used as the mail body) and save it to the path `path/to/your/docx`.\r\n\r\n    \u003e You are recommand to edit the docx file with Microsoft Word Application in web layout mode to avoid the unexpected format issue.\r\n\r\n2. Edit the header of the docx file to set the mail properties. The header should be in YAML format in this way:\r\n\r\n    ```yaml\r\n    Subject: Demo email\r\n    To: anyone@example.com\r\n    CC: p1@example.com;p2@example.com\r\n    Attachments: path/to/your/attachment1.docx;path/to/your/attachment2.msg\r\n    Importance: High\r\n    Sensitivity: Confidential\r\n    ReadReceiptRequested: True\r\n    Categories: RED CATEGORY, BLUE CATEGORY\r\n    FlagRequest: Test Flag\r\n    ReminderTime: 2024-02-29 14:00:00\r\n    ```\r\n\r\n3. Convert a docx to an Outlook Mail-Item with few lines of code:\r\n\r\n    ```python\r\n    import win32com.client\r\n    from docx2msg import Docx2Msg\r\n\r\n    docx_path = r\"path/to/your/docx\"\r\n    with Docx2Msg(docx_path) as docx:\r\n        # set display=True to display the mail in Outlook Application\r\n        mail = docx.convert(display=True)\r\n    ```\r\n\r\n4. The mail will be displayed in Outlook Application and you can see the output.\r\n\r\n### Advanced Usage with template\r\n\r\nSince `docx2msg` uses `docx-template` to render the docx body, you can use the same syntax to render the docx body and set mail properties dynamically.\r\n\r\nYou can access the `template` attribute of the `Docx2Msg` object to utilize the `docx-template` features.\r\n\r\n\u003e Go to [python-docx-template’s documentation](https://docxtpl.readthedocs.io/en/latest/) for more details.\r\n\r\nRun the following code to convert a docx to an Outlook Mail-Item with a template:\r\n\r\n```python\r\n# the context to render the docx\r\ncontext = {\r\n    \"name\": \"John Doe\",\r\n    \"age\": 30,\r\n    \"address\": \"123 Main St.\"\r\n}\r\nwith Docx2Msg(docx_path) as docx:\r\n    # use template attribute to render the docx body\r\n    docx.template.render(context)\r\n    # convert the docx to an Outlook Mail-Item\r\n    mail = docx.convert()\r\n    # display the mail in Outlook Application\r\n    mail.Display()\r\n    # save mail in draft folder\r\n    mail.Save()\r\n    # save mail as .msg file\r\n    mail.SaveAs(r\"path/to/your/output.msg\")\r\n```\r\n\r\nThe output from `convert` method will be a `MailItem` object, for further development, you can refer to the [Outlook API](https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem) for more details.\r\n\r\n### Mail Headers Syntax\r\n\r\nThe mail headers are in YAML format in the header of the docx file. The following properties are supported:\r\n\r\n\r\n| Property                    | Type     | Example                                       |\r\n|-----------------------------|----------|-----------------------------------------------|\r\n| To                          | str\\|list[str]| anyone@example.com                            |\r\n| CC                          | str\\|list[str]| p1@example.com;p2@example.com                 |\r\n| BCC                         | str\\|list[str]| p1@example.com;p2@example.com                 |\r\n| Subject                     | str      | Demo email                                    |\r\n| Attachments                 | str\\|list[str]       | path/to/your/file1.docx;path/to/your/file2.msg |\r\n| Categories                  | str      | RED CATEGORY, BLUE CATEGORY                   |\r\n| Importance                  | str\\|int      | High                                         |\r\n| Sensitivity                 | str\\|int      | Confidential                                  |\r\n| ReadReceiptRequested        | bool     | True                                          |\r\n|OriginatorDeliveryReportRequested| bool     | True                                          |\r\n| FlagRequest                 | str      | Follow up                                     |\r\n| VotingOptions               | str      | Yes;No                                 |\r\n| ReminderTime                | datetime      | 2024-02-29 14:00:00                           |\r\n|DeferredDeliveryTime         | datetime      | 2024-02-29 14:00:00                           |\r\n|ExpiryTime                   | datetime      | 2024-02-29 14:00:00                           |\r\n|FlagDueBy                    | datetime      | 2024-02-29 14:00:00                           |\r\n|ReplyRecipients              | str\\|list[str]| p1@example.com;p2@example.com                      |\r\n|SaveSentMessageFolder        | str      | 1/Auto/New                      |\r\n\r\n**Note:**\r\n\r\nFor the some properties like `Attachments`, `To`, `CC`, `ReplyRecipients` which may have a list of values, you can use the `;` to separate them.\r\n\r\nFor the `SaveSentMessageFolder` property, the example \"1/Auto/New\" refers to the folder access by `outlook.Session.Folders[1].Folders[\"Auto\"].Folder[\"New\"]` in python code, which is the sugar syntax for the `SaveSentMessageFolder` property.\r\n\r\nAll the properties are vaild properties for `Outlook.MailItem` object, so you can refer to https://learn.microsoft.com/en-us/office/vba/api/outlook.mailitem#properties for more details.\r\n\r\n### API Documentation\r\n\r\n\u003e The API documentation is coming soon...\r\n\r\n## References\r\n- pywin32: https://pypi.org/project/pywin32/\r\n- Outlook API: https://learn.microsoft.com/en-us/office/vba/api/overview/outlook\r\n- Word API: https://learn.microsoft.com/en-us/office/vba/api/overview/word\r\n- docxtpl: http://docxtpl.readthedocs.org/\r\n- jinja2: https://jinja.palletsprojects.com/en/3.0.x/","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgebra-fun%2Fdocx2msg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falgebra-fun%2Fdocx2msg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falgebra-fun%2Fdocx2msg/lists"}