python - 使用捕获的 .msg 文件内容创建新的 pdf
问题描述
print (msg.SenderName)
print (msg.SenderEmailAddress)
print (msg.SentOn)
print (msg.To)
print (msg.CC)
print (msg.BCC)
print (msg.Subject)
print (msg.Body)
我只是想采用上述内容,并将内容写入新创建的 .PDF 文件......因此,使用我在上面捕获的内容创建一个 .PDF 文件。
下面是完整的代码,我在其中打开.msg
文件并提取它的内容......它正在打开.msg
文件,并将内容正确输出到 Anaconda 提示窗口;只是还没有弄清楚如何使用 Python 将其推送到新创建的 .pdf 文件中。
import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
msg = outlook.OpenSharedItem(r"C:\Users\path\path\test_msg.msg")
print (msg.SenderName)
print (msg.SenderEmailAddress)
print (msg.SentOn)
print (msg.To)
print (msg.CC)
print (msg.BCC)
print (msg.Subject)
print (msg.Body)
count_attachments = msg.Attachments.Count
if count_attachments > 0:
for item in range(count_attachments):
print (msg.Attachments.Item)(item + 1).Filename
del outlook, msg
解决方案
推荐阅读
- .htaccess - 301 将整个域重定向到新的一个 + 几个单独的页面到新的 url
- python - 如何将您安装的变压器保存到 blob 中,以便您的预测管道可以在 AML 服务中使用它?
- php - Auth::user()->id 返回“试图获取非对象的属性”——Laravel 5.8
- c# - 在更改字段类型时命名枚举
- mysql - 如何在将 SUM() 用于另一个日期的子句中按日期使用 MIN()?
- c# - 通过 FatSecret Api 2.0 c# 获取响应
- javascript - 无法访问 webform ascx 文件中的模型
- scala - 在成功结果数之后,在列表上结束 Scala 中的过滤器
- docker - 在 Docker Image 中复制具有执行权限的文件
- c# - 为什么我的应用程序没有返回文件名?