Search code examples
pythonpython-3.xoutlook

Opening outlook with filled fields using Python


I am trying to create a function to open a new Outlook message, but I would like the message to appear already with the recipient, subject fields. So far what I have found is how to open a new Outlook window with the recipient, but I still can't get the subject to be displayed.

import webbrowser
webbrowser.open('mailto:[email protected]', new=1)

Hope u can help me, ty.


Solution

  • mailto would work fine as long as you don't want HTML body or attachments. You can specify to/cc/bbc, subject, and body.

    Something along the lines:

    mailto:[email protected]?subject=Test%20Subject&body=Test%20body&[email protected]&[email protected]
    

    And it will work under any OS and any email client.