简体   繁体   中英

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?

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM