Jameel Moideen
Jameel Moideen

Reputation: 7941

How to get the sender's email address from Outlook?

I have write the code for reading inbox messages from the outlook by using exchange server. below are the code for reading.

FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, itemview);

the results get successfully. But not getting the sender's Email address in that results. How to get the sender's Email address?

Upvotes: 3

Views: 2109

Answers (1)

Blachshma
Blachshma

Reputation: 17395

You should cast the Item to a EmailMessage and then you can view the From property.

So for example:

var mailItems = findResults.Where(x => x is EmailMessage).Cast<EmailMessage>().ToList();

foreach (EmailMessage item in mailItems)
{
     Console.WriteLine(item.From.Address);
}

Upvotes: 5

Related Questions