-2

So far i have been able to do it in VBA:

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)

But i want to do it via Python.(i am not looking for someone to convert it for me i am looking the right way to read mail header).

mayure098
  • 111
  • 1
  • 5
  • This seems like you are looking for someone who converts your code from VBA to Python? If yes, I recommend reading the [the help pages](http://stackoverflow.com/help) especially the section ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask) – Markus Jun 27 '17 at 08:14
  • i am not looking for someone to convert it for me i am looking the right way/method to read mail header. i am not sure if it is possible. – mayure098 Jun 27 '17 at 10:41
  • The Outlook object model is exposed via COM - thats what your VBA uses to talk to it - Python can do the same (via win32com) E.g. https://stackoverflow.com/questions/18101479/how-to-send-html-format-email-with-emebbed-imagesnot-attachment-using-outlook – Alex K. Jun 27 '17 at 11:14
  • do i need internet connectivity, outlook authentication. – mayure098 Jun 27 '17 at 11:17

1 Answers1

1

found the solution:

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")
SiHa
  • 7,830
  • 13
  • 34
  • 43
mayure098
  • 111
  • 1
  • 5