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 10:24am

You should post the code you tried that didn't work but all you need to do is change the original code you posted like

            PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
            FindItemsResults<Item> unreadMessages = boundFolder.FindItems(unreadSearchFilter, itemView);
            service.LoadPropertiesForItems(unreadMessages, psPropset);
Cheers
Glen

Free Windows Admin Tool Kit Click here and download it now
April 8th, 2015 12:42am

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

Other recent topics Other recent topics