Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load MimeContent via EWS in Exchange Server 2013

I have a problem with loading MimeContent property using EWS with Exchange Server 2013. Here's what I do:

var propertySet = new PropertySet{
            ItemSchema.Subject,
            ItemSchema.TextBody,
            ItemSchema.DateTimeCreated,
            ItemSchema.LastModifiedTime
        };

var item = Item.Bind(mailbox.ExchangeServiceInstance, itemId, propertySet);

Mailbox, permissions, PullSubscription & ExchangeService are setup and working, 'itemId' is the correct, existing one. This code works and I'm able to access the loaded properties.

But when I try to load MimeContent right after it, I get an error:

var binaries = new PropertySet(BasePropertySet.IdOnly, ItemSchema.MimeContent);
item.Load(binaries);

The exception I get is:

'Microsoft.Exchange.WebServices.Data.ServiceResponseException' occurred in Microsoft.Exchange.WebServices.dll

A referenced period is missing.

I couldn't google-find any similar issues with this exception related to EWS, or any similar problems with loading MimeContent. I keep trying to figure it out myself, but can anyone give me a hint where to dig?

like image 833
Natu Nuarat Avatar asked Apr 18 '16 09:04

Natu Nuarat


1 Answers

Found it! The problem was in the TimeZone settings. They say it's a rare problem, which depends on where and how your Exchange Server is installed.

I only added TimeZoneInfo.Utc in ExchangeService's constructor, and everything works now.

var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1, TimeZoneInfo.Utc)

Hope it might help someone else.

like image 198
Natu Nuarat Avatar answered Sep 28 '22 02:09

Natu Nuarat