如何用python阅读电子邮件的internet标题?

如何用python阅读电子邮件的internet标题?,python,email,msg,Python,Email,Msg,我想阅读我收到的邮件的internet标题,并在在线门户上对其进行分析,以检查邮件是否恶意。 我浏览了很多网站,并认为win32com将帮助我解决这个问题。遗憾的是,虽然我可以提取很多东西,但我无法提取internet标题。 这就是我到目前为止所做的: import win32com.client outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") inbox=outlook.GetDef

我想阅读我收到的邮件的internet标题,并在在线门户上对其进行分析,以检查邮件是否恶意。 我浏览了很多网站,并认为win32com将帮助我解决这个问题。遗憾的是,虽然我可以提取很多东西,但我无法提取internet标题。 这就是我到目前为止所做的:

 import win32com.client
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox=outlook.GetDefaultFolder(6)
messages = inbox.Items
message = messages.GetLast()
mess=message.Body            #Body attribute fetches the body of the message
print mess                   #There is no InternetHeader attribute
message变量没有Headers或internetiaders属性。链接:


请帮助我检索邮件标题。提前谢谢你

您似乎需要使用
MailItem.propertyaccessor.GetProperty(String)
读取
PR\u TRANSPORT\u MESSAGE\u HEADERS
MAPI属性,如下链接所述:

PR_TRANSPORT_MESSAGE_HEADERS
DASL属性名称为“”。它不是链接,而是用作函数参数的字符串

您的代码如下所示:

 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)

我希望这就是您要找的。

非常感谢!那正是我要找的!