如何使用outlook web access从python发送电子邮件?

如何使用outlook web access从python发送电子邮件?,python,email,outlook,outlook-web-app,Python,Email,Outlook,Outlook Web App,如果我的工作失败,我需要用python发送电子邮件,但是由于公司的政策,我只能使用Outlook Web Access。我如何从python连接到Outlook Web Access以发送电子邮件?我不能为此负责,但我可以为您提供一个可能的解决方案 以下是链接: 这是密码 import win32com.client s = win32com.client.Dispatch("Mapi.Session") o = win32com.client.Dispatch("Outlook.Applic

如果我的工作失败,我需要用python发送电子邮件,但是由于公司的政策,我只能使用Outlook Web Access。我如何从python连接到Outlook Web Access以发送电子邮件?

我不能为此负责,但我可以为您提供一个可能的解决方案

以下是链接: 这是密码

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问题可以在这里找到:

检查这些链接:我还应该提到我正试图从mac/linuxAh发送电子邮件,我明白了。这是一个重要的警告。我会做一些挖掘。你还在挖掘吗?不幸的是,没有,我在一个工作场所,在那里再次挖掘是合理的。。。