我想阅读收到的邮件的互联网 header ,并在在线门户上对其进行分析,以检查该邮件是否是恶意的。 我浏览了很多网站,认为 win32com 会帮助我解决这个问题。可悲的是,虽然我可以提取很多东西,但我无法提取互联网 header 。 这就是我到目前为止所做的:
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 属性。链接:https://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.mailitem_properties.aspx
请帮助我检索我的邮件 header 。预先感谢您!
最佳答案
您似乎需要使用 MailItem.PropetyAccessor.GetProperty(String)
读取 PR_TRANSPORT_MESSAGE_HEADERS
MAPI 属性,如以下链接所述:
https://msdn.microsoft.com/VBA/Outlook-VBA/articles/propertyaccessor-getproperty-method-outlook
PR_TRANSPORT_MESSAGE_HEADERS
DASL 属性名称为“http://schemas.microsoft.com/mapi/proptag/0x007D001F ”。它不是链接,而是用作函数参数的字符串。
您的代码将如下所示:
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)
我希望这就是您正在寻找的内容。
关于python - 如何在Python中读取电子邮件的互联网标题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44780272/