如何在 python 中阅读互联网 headers 的电子邮件?
How to read internet headers of email in python?
我想阅读互联网 headers 我收到的一封邮件,并在在线门户网站上对其进行分析,以检查邮件是否是恶意的。
我浏览了许多网站,认为 win32com 会帮助我解决这个问题。可悲的是,虽然我可以提取很多东西,但我无法提取互联网 headers。
这是我到目前为止所做的:
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
消息变量没有 Headers 或 InternetIeaders 属性。 Link : https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem_properties.aspx
请帮我找回我的消息headers。提前致谢!
您似乎需要使用 MailItem.PropetyAccessor.GetProperty(String)
阅读 PR_TRANSPORT_MESSAGE_HEADERS
MAPI 属性,如下所述 link:
https://msdn.microsoft.com/VBA/Outlook-VBA/articles/propertyaccessor-getproperty-method-outlook
PR_TRANSPORT_MESSAGE_HEADERS
DASL 属性 名称是“http://schemas.microsoft.com/mapi/proptag/0x007D001F”。它不是 link,而是用作函数参数的字符串。
您的代码将如下所示:
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)
希望这就是您要找的。
我想阅读互联网 headers 我收到的一封邮件,并在在线门户网站上对其进行分析,以检查邮件是否是恶意的。 我浏览了许多网站,认为 win32com 会帮助我解决这个问题。可悲的是,虽然我可以提取很多东西,但我无法提取互联网 headers。 这是我到目前为止所做的:
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
消息变量没有 Headers 或 InternetIeaders 属性。 Link : https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem_properties.aspx
请帮我找回我的消息headers。提前致谢!
您似乎需要使用 MailItem.PropetyAccessor.GetProperty(String)
阅读 PR_TRANSPORT_MESSAGE_HEADERS
MAPI 属性,如下所述 link:
https://msdn.microsoft.com/VBA/Outlook-VBA/articles/propertyaccessor-getproperty-method-outlook
PR_TRANSPORT_MESSAGE_HEADERS
DASL 属性 名称是“http://schemas.microsoft.com/mapi/proptag/0x007D001F”。它不是 link,而是用作函数参数的字符串。
您的代码将如下所示:
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)
希望这就是您要找的。