Python: Open Thunderbird to write new mail with attached file

亡梦爱人 提交于 2019-12-01 21:20:47

Start Thunderbird with the command line argument "-compose". More about it at http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29

Using the information from mozillazine listed above, I was able to get this to work with Python 2.7 on Windows 7

import subprocess
tbirdPath = r'c:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe'
to = 'recipiant@example.com'
subject = 'Hello'
body = '<html><body><h1>Header</h1>This is the body<br></body></html>'
composeCommand = 'format=html,to={},subject={},body={}'.format(to, subject, body)
subprocess.Popen([tbirdPath, '-compose', composeCommand])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!