如何使用Outlook Web Access从Python发送电子邮件?

4

如果我的任务失败,我需要使用Python发送电子邮件,但由于公司政策,我只能使用Outlook Web Access。那么如何从Python连接到Outlook Web Access以发送电子邮件呢?


请查看以下链接: https://dev59.com/8Ww15IYBdhLWcg3w4_3k http://www.holovaty.com/writing/python-outlook-web-access/ - Vaibhav
你解决了这个问题吗?我也处于同样的情况。 - Kevin liu
1个回答

2
我不能为此负责,但我可以为您提供可能的解决方案。
这是链接:http://win32com.goermezer.de/content/view/227/192/ 这是代码。
import win32com.client

s = win32com.client.Dispatch("Mapi.Session")
o = win32com.client.Dispatch("Outlook.Application")
s.Logon("Outlook2003")

Msg = o.CreateItem(0)
Msg.To = "recipient@domain.com"

Msg.CC = "more email addresses here"
Msg.BCC = "more email addresses here"

Msg.Subject = "The subject of you mail"
Msg.Body = "The main body text of you mail"

attachment1 = "Path to attachment no. 1"
attachment2 = "Path to attachment no. 2"
Msg.Attachments.Add(attachment1)
Msg.Attachments.Add(attachment2)

Msg.Send()

这很酷,我必须使用它。 相关的SO问题可以在这里找到:Python - 通过Outlook 2007/2010和win32com发送HTML格式的电子邮件


我还应该提到,我正在尝试从Mac/Linux发送电子邮件。 - mmmtoasted
啊,我明白了。那是一个重要的警告。 我会进行一些调查。 - Quentin
你还在挖掘吗? - Nick
很遗憾,我还没有,但我现在的工作环境让我有可能再次深入研究这个问题... - Quentin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接