python - Python win32com:设置电子邮件标题
问题描述
我有一个问题要使用库 win32com 在 python 中写入电子邮件标题。但我不确定这是否可能。
我们可以使用以下方式读取电子邮件标题:
import win32com.client
outlook =win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
mess=message.Body
internet_header = message.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F")
print(internet_header)
但我不知道我们是否可以使用类似的方法设置电子邮件标题。使用类似的东西不起作用:
new_mail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F", internet_header)
任何想法?
谢谢
解决方案
要在外发电子邮件上设置 MIME 标头,请在 PS_INTERNET_HEADERS 命名空间中设置命名属性:
message.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/X-My-Header", "some value")
推荐阅读
- python - 如何将本地数据加载到我的 tensorflow/keras-model 中?
- wordpress - 如何在 wp-admin/post.php 中更改背景颜色
- r - 在列中重复序列
- julia - 附加!当自定义类型混合时,“没有方法匹配长度”失败
- php - 防止删除换行符“\n”“\r”的方法?
- c# - 尝试调试示例 Xamarin.Forms 应用程序时,Visual Studio 2017 (v15.9.14) 显示“部署失败”
- flutter - 类型列表
不是“地图”类型的子类型 ' - python - gethostbyaddr 给出不同的主机名
- python - 如何修复 AttributeError:类型对象“CookieJar”没有属性“LWPCookieJar”?
- javascript - 你不应该在外面使用
当它是