在 python 中创建 Outlook 草稿电子邮件而无需启动 Outlook 应用程序 [英] Create outlook draft email in python with out launching outlook application

查看:55
本文介绍了在 python 中创建 Outlook 草稿电子邮件而无需启动 Outlook 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建电子邮件草稿并以 msg 格式保存,而无需启动 Outlook 应用程序.

I need to create an email draft and save in msg format without launching the outlook application.

(或)

我有一个现有的 msg 文件草稿,我需要修改该文件的发件人、正文和附件并另存为 msg 文件.

I have an existing draft msg file, I need to modify the sender, body, and attachment to that file and save as msg file.

我尝试了 win32,它工作正常,但它正在我的系统中启动 Outlook 应用程序.在我的服务器中,没有 Outlook 应用程序.

I tried win32 it is working fine, but it is launching the outlook application in my system. In my server, there is no outlook application.

你能告诉我有没有其他方法可以生成 msg 文件.

Can you please tell me is there any other ways to generate the msg file.

推荐答案

如果您不想使用 Outlook 对象模型,您几乎只能使用像 Aspose(它无需安装 Outlook 即可处理 MSG 文件,但您的里程可能会有所不同)或 Redemption(披露:我是它的作者) - 它需要安装 MAPI 系统(这意味着必须安装 Outlook),但它不会启动Outlook,如果您使用的是 RDOSession.CreateMsgFile(由设置各种 RDOMail 属性和/或使用 RDOMail.Import 后跟 RDOMail.Save.

If you don't want to to use the Outlook Object Model, you are pretty much limited to either using a library like Aspose (it handles MSG files without having to install Outlook, but your mileage may vary) or Redemption (disclosure: I am its author) - it requires the MAPI system to be installed (which means Outlook must be installed), but it won't start Outlook if you are using RDOSession.CreateMsgFile (ollowed by setting various RDOMail properties and/or importing an existing MSG file using RDOMail.Import followed by RDOMail.Save.

根据 OP 请求更新.我不使用 Python,但在 VB 脚本中,它类似于以下内容:

Update per OP request. I don't use Python, but in VB script it would be something like the following:

Set Session = CreateObject("Redemption.RDOSession")
set newMsg = Session.CreateMessageFromMsgFile("c:\temp\new.msg")
newMsg.Import("c:\temp\template.msg", 3)
newMsg.Body = "updated body"
newMsg.Save

这篇关于在 python 中创建 Outlook 草稿电子邮件而无需启动 Outlook 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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