Python: Open Thunderbird to write new mail with at

2019-03-03 04:20发布

I would like to open Thunderbird on Debian AND Windows with an attached file for a new email.

So I would like to do the same as in this thread but the posted solution does not work:

Python open email client with attachment

I have the very same problem as user2686223. The file will not be attached to the mail. Can anyone help me with this?

Maybe with another solution?

EDIT: This is now how it works:

import os
os.system("thunderbird -compose to='test@test.de',subject='subject',body='body',attachment='/path/to/file'")

2条回答
姐就是有狂的资本
2楼-- · 2019-03-03 05:03

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])
查看更多
Explosion°爆炸
3楼-- · 2019-03-03 05:07

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

查看更多
登录 后发表回答