使用python win32com库发送一个AppointmentIthem [英] Send an AppointmentIthem with python win32com library

查看:72
本文介绍了使用python win32com库发送一个AppointmentIthem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Python脚本,以创建一个简单的AppointmentItem并使用win32com库将其发送给某些收件人.我在此链接中找到了所有文档和一些VBA示例: https://msdn.microsoft.com 和一切似乎都清晰易懂.但是,在我的脚本中,尽管创建了AppointmentItem并解决了收件人,但我无法发送它.以下仅是代码外观的示例.

I'm developing a Python scripts to create a simple AppointmentItem and send it to some recipients using win32com library. I found all the documentation and some VBA examples in this link: https://msdn.microsoft.com‎ and everything seems to be clear and well exained. But, in my script, though the AppointmentItem is created and the Recipients resolved, I am not able to send it. The following is just an example of how looks the code.

outlook = win32com.client.Dispatch("Outlook.Application")
ns = outlook.GetNamespace("MAPI")
ns.Logon(profilename)

App = outlook.CreateItem(1)
App.Subject = "subject"
App.Body = "Meeting"
App.Location = "München"

App.Recipients.Add(recipient)
App.Recipients.ResolveAll()

App.Send()

我一定要有一个Exchange帐户吗?有避免该问题的解决方法吗?我可以使用以下库使用此库发送普通电子邮件:

Should I have necessarily an Exchange Account? Is there a workaround to avoid this problem? I can send normal email using this library using:

Msg = outlook.CreateItem(0)

而不是创建约会(第四行).因此,我尝试发送一封带有约会附件的电子邮件,但该电子邮件中没有附件.

instead of creating an appointment (fourth line). I tried, for this reason, to send an email with the appointment in attachment, but in the email there is no attachment.

推荐答案

我找到了解决方案,并希望将其发布,以帮助可能需要它的其他人.

I found the solution and I'd like to post it, in order to help someone else, who may need it.

只需要再增加一行代码即可.该约会应更改为会议.

It's necessary just one code line more. The appointment should be changed into a meeting.

outlook = win32com.client.Dispatch("Outlook.Application")
ns = outlook.GetNamespace("MAPI")
ns.Logon(profilename)

App = outlook.CreateItem(1)
App.Subject = "subject"
App.Body = "Meeting"
App.Location = "München"

App.MeetingStatus = 1
App.Recipients.Add(recipient)
App.Recipients.ResolveAll()

App.Send()

这篇关于使用python win32com库发送一个AppointmentIthem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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