-->

How to get Out of Office for another mailbox

2020-03-30 07:30发布

问题:

I'm trying to get the Out of Office settings for a given mailbox by using EWS/EWS Managed API 2.0.

The setup is the following; a single "service account/mailbox" reads other mailbox calendars and Out of Office settings. The calendar part is easy using the EWS Managed API, but I can't seem to figure out how to get the Out of Office settings by using the API. The API has a method called GetUserOofSettings(string smtpAddress) but this returns access denied if the caller the given smtpAddress do not belong to the mailbox making the request.

Because of this I have tried to get the Out of Office settings by using the WSDL/service published by Exchange directly. By doing so, I'm able to get the Out of Office message for other mailboxes using the operation GetMailTips, but this takes me only half the way because I'm not able to get the duration.

My question(s) are: Is it possible to get other mailboxes Out of Office settings using the EWS Managed API if not is it possible to get the Out of Office duration by calling the EWS service directly?

回答1:

You can use GetUserOofSettings operation, but in order to retrieve other account's oof setting you need add a SOAP header ExchangeImpersonation. And note that

The calling account must have the ms-exch-impersonation right on the Client Access server and the ms-exch-MayImpersonate right on either the mailbox database that contains the mailbox to impersonate or the Active Directory User/Contact object.

refer to http://msdn.microsoft.com/en-us/library/aa565690(v=exchg.140).aspx



回答2:

It IS possible to get the duration by using the EWS service directly. One just needs to set the start/end time of the OOF. Oops..

However, I would prefer if this was supported using the EWS Managed API so please let me know if this is possible somehow.