Python:打开Thunderbird撰写新邮件并附加文件
我想在Debian和Windows上打开Thunderbird,并且希望新邮件中能附带一个文件。
我想做的事情和这个讨论串里说的一样,但那里的解决方案对我没用:
我遇到的问题和用户2686223的一模一样。文件就是无法附加到邮件上。有没有人能帮我解决这个问题?
也许可以提供其他的解决办法?
编辑:现在的解决方法是这样的:
import os
os.system("thunderbird -compose to='test@test.de',subject='subject',body='body',attachment='/path/to/file'")
2 个回答
3
根据上面提到的mozillazine的信息,我成功在Windows 7上用Python 2.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])
5
用命令行参数“-compose”启动Thunderbird。想了解更多,可以查看这个链接:http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29