December 14, 2021

Outlook Trap: Get Real Email of Meeting Organizer (VBA)

I have stumbled upon a nontrivial use case for automatically handling items in Outlook VBA based on the Sender Email. This is when the item was sent "on behalf of".

Issue description

Use Case 1
In Microsoft Outlook, if you get a Google calendar invitation, it will be sent by calendar-notification@google.com on behalf of the real organizer (see screenshot below)


(or another calendar email if it is a secondary calendar.)
Also if you get a meeting forwarded it will be sent on behalf of the organizer.

Outlook VBA Sent of behalf of 
https://stackoverflow.com/questions/57355562/capturing-actual-on-behalf-of-email-id-from-outlook-mail-instead-of-the-sender-i

OutlookMail.Sender.Address - will give the OnBehalfOf Email but it works only for Emails - not for Meetings.

Solution

The trick for getting the email of the real organizer is to use the ReplyRecipients property.
More precisely the organizer email will match .ReplyRecipients.Item(1).Address

You can see an example of how I have used it, for example, in my macro to automatically mark appointment coming from my Google calendar as private.
Or for the macro I use to categorize based on the recipients/sender email addresses.

See also

Outlook VBA: How to get Appointment Organizer or Email Sender Email | Thierry Dalon's Blog

Outlook: How to automatically categorize emails and meetings based on recipients/sender email domain (VBA) | Thierry Dalon's Blog

vba - Capturing actual on behalf of email id from outlook mail instead of the sender id - Stack Overflow

No comments:

Post a Comment