Unable to load MimeContent via EWS in Exchange Server 2013
Asked Answered
K

1

7

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?

Koressa answered 18/4, 2016 at 9:53 Comment(2)
What happens if you include ItemSchema.MimeContent in the original property set (the one you use when you bind)?Jupon
@YacoubMassad Same thing, unfortunately.Koressa
K
9

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.

Koressa answered 18/4, 2016 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.