Our customers have a common ask wherein they would like to check if the organization’s employees are available in office or out of office on a given day. With Exchange Web Services (EWS) being the flagship API for Exchange related development, the relevant call they come across is GetUserOofSettings in EWS Managed API.
However, when you make this call from a normal Exchange user account, you get an error message saying:
"Access is denied. Check credentials and try again".
The reason being GetUserOofSettings call works only for the users with the Exchange impersonation permissions. As for example, assume that the EWS call is made using the User A’s credential and he’s trying to access User B’s OOF settings. In that case, User A needs to have Exchange impersonation permissions on User B’s mailbox.
In case if you’re requirement is not to run the EWS application under impersonation service account then we could use Mail Tips to fetch the automatic reply set by the Exchange user.
Currently, we don’t have a EWS Managed API call to retrieve the Mail Tips. However, we have the method GetMailTips operation available with Exchange Web Services to retrieve the out of office settings.
We can create the soap request for GetMailTips operation in the following ways:
- Use the Visual Studio to generate the proxy classes for EWS and then use it write the code for GetMailTips operation.
- Post the request directly from your EWS managed API application.
Here is a sample using EWS Managed API:
Here is the response that I got from server:
Though the GetMailTips operation is NOT yet available with EWS Managed API, with the above sample using raw HTTP EWS SOAP request we can easily retrieve the required information. For more details, refer the following articles:
- GetMailTips Operation