2014-09-06 30 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])