Lucian
Lucian

Reputation: 894

How to get eMail data when clicking an email, using Outlook API in C#


I am using .NET 4.0 on a Win7 64bit machine.
I am trying to get email details when I click on an email in Outlook. When I click on an email, I catch the event that notifies me that a new item is clicked/loaded into memory on an ItemLoad(object Item) callback, but the param is empty because, as the documentation says, this event occurs when the Outlook item begins to load into memory, and it cannot be accessed. Is there a way to access the data related to the clicked item? My code:

m_oApp = new Outlook.Application();
.....
m_oApp.ItemLoad += m_oApp_ItemLoad;
.....
void m_oApp_ItemLoad(object Item)
{
       //Outlook.MailItem mail = (Outlook.MailItem)Item;//Item here is a NULL object
}

Upvotes: 0

Views: 204

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49405

In the ItemLoad event handler you can subscribe to the item-level events such as Open, Read, ReadComplete and etc.

You may consider using the SelectionChange event of the Explorer class instead. It is fired when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface. This event also occurs when the user (either programmatically or via the user interface) clicks or switches to a different folder that contains items, because Outlook automatically selects the first item in that folder.

Upvotes: 1

Related Questions