使用Python发送Outlook电子邮件时出错

时间:2019-11-20 06:00:19

标签: python-3.x email outlook test-runner

这是我在互联网上找到并根据需要修改的代码:

outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.To = 'W57007'
mail.Subject = 'Message subject'
mail.Body = 'Message body'
mail.HTMLBody = '<h2>HTML Message body</h2>' #this field is optional

# To attach a file to the email (optional):
# attachment  = "Path to the attachment"
# mail.Attachments.Add(attachment)

mail.Send()

运行此命令时,出现以下错误:

mail.Send()

pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)

请帮助我缓解此错误。需要任何其他详细信息,请让我知道!

enter image description here

0 个答案:

没有答案