Skip to content
Advertisement

Extract sender’s email address from Outlook Exchange in Python using win32

I am trying to extract the sender’s email address from outlook 2013 using win32 package in python. There are two kinds of email address type in my Inbox, exchange and smtp. If I try to print the the sender’s email address of Exchange type, I am getting this:

JavaScript

I have already gone through this link but couldn’t find a function through which I can extract the smtp address.

Below is my code:

JavaScript

Currently all the Email Address are coming like this:

JavaScript

I found a solution to this in VB.net link but don’t know how to rewrite the same thing in Python.

Advertisement

Answer

Firstly, your code will fail if you have an item other than MailItem in the folder, such as ReportItem, MeetingItem, etc. You need to check that the Class property is 43 (olMail).

Secondly, you need to check the sender email address type and use the SenderEmailAddress property only for the “SMTP” address type. In VB:

JavaScript
Advertisement