[使用python发送Outlook电子邮件

问题描述 投票:0回答:1

我想通过python发送Outlook电子邮件,并且在下面的脚本中找到了我

import win32com.client
from win32com.client import Dispatch, constants
const=win32com.client.constants
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "I AM SUBJECT!!"
newMail.BodyFormat = 2 
newMail.HTMLBody = "<HTML><BODY>Enter the <span style='color:red'>message</span> text here.</BODY></HTML>"
newMail.To = "[email protected]"
newMail.display()
newMail.Send()

一切正常,直到newMail.Send(),它会出现此错误

Traceback (most recent call last):
  File "<ipython-input-46-7e8e370e48a8>", line 1, in <module>
    newMail.Send()
File "<COMObject CreateItem>", line 2, in Send
com_error: (-2147467260, 'Operation aborted', None, None)
python email outlook automation win32com
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.