[英]Send Outlook Template Through Python
我有以下代码将 email 发送给指定的收件人,但我尝试发送的 email 是标准的、长的和格式化的。 是否可以将原始 email 保存为模板,然后在我的代码中引用它而不是在这里创建 email?
olFormatHTML = 2
olFormatPlain = 1
olFormatRichText = 3
olFormatUnspecified = 0
olMailItem = 0x0
obj = win32com.client.Dispatch("Outlook.Application")
newMail = obj.CreateItem(olMailItem)
newMail.Subject = "The Gap: " + str(res)
newMail.BodyFormat = olFormatHTML #or olFormatRichText or olFormatPlain
newMail.HTMLBody = xxxxxxxxxx
newMail.To = xxxxxxxxxxxxxx
newMail.Send()
你可以打开模板 email 得到 html 在里面
outlook = win32.Dispatch("Outlook.Application").GetNamespace("MAPI")
template_mail = outlook.OpenSharedItem(<template email path>)
template_html = template_mail.HTMLBody
然后放入newMail
newMail.HTMLBody = template_html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.