How to retrieve from email from Exchange server Mail Account ?

Dear All,

I get the email in my mail box from hardikramwani@hotmail.com.

I need to retrieve the from email address but i am unable to get this.

   

Following is code i am using.

Folder boundFolder = Folder.Bind(service, WellKnownFolderName.Inbox);
                FindItemsResults<Item> unreadMessages = boundFolder.FindItems(unreadSearchFilter, itemView);

                if (unreadMessages != null && unreadMessages.Items != null && unreadMessages.Items.Count > 0)
                {
                    foreach (EmailMessage message in unreadMessages)
                    {

                        string subject = message.Subject.ToString();
                        string strfromEmail = message.From.Address.ToString(); // I got Error of Object Refrence
                        string strDisplayName = message.From.Name.ToString();

  }
                }

How can i retrieve from email using C#? 

Thanks and regards,

Hardik Ramwani


April 6th, 2015 6:26am

The From Address isn't returned when you use FindItems see https://msdn.microsoft.com/en-us/library/office/aa566107%28v=exchg.150%29.aspxto return the From Addresss you need to use either Load or loadpropertiesforitems see http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx

Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
April 6th, 2015 11:57pm

Hi Glen,

Thanks for your reply, Do you have any source code for this.

From that i can refer and Implement, I have tried but not getting any success.

Thanks

Hardik

April 7th, 2015 3:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics