2014-09-06 33 views
0

我想在Debian和Windows上打开Thunderbird,并附上一个新电子邮件文件。Python:打开雷鸟用附加文件写新邮件

所以我想这样做的一样,在这个线程,但张贴的解决方案不起作用:

Python open email client with attachment

我也有同样的问题,因为user2686223。该文件不会附加到邮件。谁能帮我这个?

也许用另一种解决方案?

编辑:现在这是它如何工作的:

import os 
os.system("thunderbird -compose to='[email protected]',subject='subject',body='body',attachment='/path/to/file'") 

回答

0

更多关于它的使用上面列出MozillaZine的信息,我能得到这与Python 2.7在Windows 7

工作
import subprocess 
tbirdPath = r'c:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe' 
to = '[email protected]' 
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])