使用 Python Win32Com.Client 发送电子邮件发送错误 [英] Sending Email with Python Win32Com.Client Send Error

查看:248
本文介绍了使用 Python Win32Com.Client 发送电子邮件发送错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的脚本,可以通过 Python win32com.client 在 Outlook 上发送消息.我可以创建电子邮件并格式化我的正文,但是当我尝试执行 newmail.Send()

我遇到了一个无法弄清楚的错误.

下面是我的代码和错误:

obj = win32com.client.Dispatch("Outlook.Application")newMail = obj.CreateItem(olMailItem)newMail.Subject = "主题"newMail.Body = "实际邮件"newMail.To = "test@test.com"newMail.Send()

我收到以下错误:

回溯(最近一次调用最后一次):文件<pyshell#105>",第 1 行,在 <module> 中newMail.Send()文件",第 2 行,发送pywintypes.com_error: (-2147467260, '操作中止', 无, 无)

有人处理过这个吗?除了发送功能外,其他一切都有效

解决方案

On

<块引用>

newMail = obj.CreateItem(olMailItem)

使用类型值而不是 类型名称

示例

<块引用>

newMail = obj.CreateItem(0)

I have my script to send out messages on Outlook via Python win32com.client. I can create the email and format my body but when I try to do newmail.Send()

I am getting an error I cannot figure out.

Below is my code along with the error:

obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "Subject"
newMail.Body = "Actualemail"
newMail.To = "test@test.com"
newMail.Send()

I get the follow error :

Traceback (most recent call last):
  File "<pyshell#105>", line 1, in <module>
    newMail.Send()
  File "<COMObject CreateItem>", line 2, in Send
pywintypes.com_error: (-2147467260, 'Operation aborted', None, None)

Anyone ever deal with this? Everything else works but the send function

解决方案

On

newMail = obj.CreateItem(olMailItem) 

Use the type value instead of the type name

Example

newMail = obj.CreateItem(0)

这篇关于使用 Python Win32Com.Client 发送电子邮件发送错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆