Python win32com:设置电子邮件头

Python win32com:设置电子邮件头,python,python-3.x,outlook,pywin32,win32com,Python,Python 3.x,Outlook,Pywin32,Win32com,我有一个问题需要使用库win32com在python中写入电子邮件头。 但我不确定这是否可能 我们可以使用以下方法读取电子邮件标题: import win32com.client outlook =win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox=outlook.GetDefaultFolder(6) messages = inbox.Items message = messages.GetLas

我有一个问题需要使用库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_头命名空间中设置命名属性:

 message.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/X-My-Header", "some value")

要在传出电子邮件上设置MIME标头,请在PS_INTERNET_标头命名空间中设置命名属性:

 message.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/X-My-Header", "some value")

您是否在收到的邮件上设置PR_传输_邮件_标题?为什么?或者您正在尝试在传出邮件上设置MIME标题?我需要发送存储在电子邮件标题中的电子邮件Azure信息保护分类。在C#中,等效的方法将使用SetExtendedProperty()方法。您是否在收到的消息上设置PR_TRANSPORT_MESSAGE_头?为什么?或者您正在尝试在传出邮件上设置MIME标题?我需要发送存储在电子邮件标题中的电子邮件Azure信息保护分类。在C#中,等效方法将使用SetExtendedProperty()方法。