Exchange Web Service – “You must load or assign this property before you can read its value” error message when trying to read message property

Recently I was writing some C# code to connect to Exchange Web Service and get email attachments. While trying to get “From” email address property, I got an exception “You must load or assign this property before you can read its value”.

The problem is that even when you have the message item, property values are not loaded, and hence can not be read. What you need to do then is call Load() method on message object.

FindItemsResults findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(mailboxPageSize));

foreach (Item item in findResults.Items)
{
      EmailMessage message = EmailMessage.Bind(service, item.Id, new PropertySet(ItemSchema.Attachments));

      message.Load();

      string fromAddress = message.From.Address;

      //Do other stuff
}
Advertisements

How to Disable OneNote 2013 Clipping Tool

After you install OneNote 2013, an icon is placed in taskbar notification area, from which you can access clipping tool, create new note or open OneNote.

To remove notification icon, open OneNote, click on File and select Options. Under Display, deselect option “Place OneNote icon in the notification area of the taskbar”.

OneNote