Home:ALL Converter>Retreiving a Receipints Email Address in Win32Com

Retreiving a Receipints Email Address in Win32Com

Ask Time:2021-09-22T04:46:15         Author:Peter Mattmann

Json Formatter

I'm using win32com with Python to get some stuff done with Outlook. While I manage to get the email address of a particular emails' sender, I'm not able to do this with the recipient.

I was only able to get the recpients name by doing this:


If I do this:


I get this:

<COMObject <unknown>>

I do get the senders address with the following code:


but this won't work with "to" or "recipients".

Thanks for the help!

Author:Peter Mattmann,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275369/retreiving-a-receipints-email-address-in-win32com
Eugene Astafiev :

The MailItem.Recipients property returns a Recipients collection that represents all the recipients for the Outlook item. Use Recipients (index), where index is the name or index number, to return a single Recipient object. The name can be a string representing the display name, the alias, or the full SMTP email address of the recipient.\nThe Recipient.Address property returns a string representing the email address of the Recipient.\nThe Recipient.Type property returns or sets a Long representing the type of recipient. Can be one of the OlMailRecipientType enumeration.\nrecipients = message.Recipients\n\nfor recipient in recipients_list:\n #Now that the for loop has gone into the Recipient Collection, this should print the recipient name\n print(recipient)\n #This is the "Address", but for me they all appeared as Exchange Users, rather than explicit email addresses (SMTP)\n print(recipient.Address)\n #I used this code to get the actual addresses (SMTP)\n print(recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress)\n",