2017-06-27 23 views
-2

到目前爲止,我已經能夠做到在VBA:如何打開Outlook郵件頭與Python(2.7)

Const PR_TRANSPORT_MESSAGE_HEADERS = "http://schemas.microsoft.com/mapi/proptag/0x007D001E" 
Dim olkPA As Outlook.PropertyAccessor 
Set olkPA = olkMsg.PropertyAccessor 
GetInetHeaders = olkPA.GetProperty(PR_TRANSPORT_MESSAGE_HEADERS) 

但我想通過Python做到這一點(我不是找人。轉換爲我我正在尋找正確的方式來閱讀郵件標題)。

+0

這似乎是你正在尋找的人誰是你的代碼轉換VBA到Python?如果是的話,我推薦閱讀[幫助頁面](http://stackoverflow.com/help),特別是[我應該避免詢問什麼類型的問題?](http://stackoverflow.com/help/不要問) – Markus

+0

我不想找人爲我轉換它我正在尋找正確的方式/方法來閱讀郵件標題。我不確定這是否可能。 – mayure098

+0

Outlook對象模型通過COM公開 - 這就是你的VBA使用它來交談的東西 - Python可以做同樣的事情(通過win32com)例如, https://stackoverflow.com/questions/18101479/how-to-send-html-format-email-with-emebbed-imagesnot-attachment-using-outlook –

回答

1

找到了解決辦法:

import win32com.client 

def internetheader(filename): 
    outlook=win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") 
    msg = outlook.OpenSharedItem(filename) 
    internet_header= msg.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F") 
    print internet_header 

internetheader("test.msg") 
相關問題