EWS: Update Out-of-Office (OOF) sample application 5/5 (1)

This sample program shows how the OOF message can be manipulated using the EWS Managed API.  Full source (Visual Studio 2013) is included, and the program can be run from the command-line (so can be incorporated into scripts) or with UI.  When run from the Visual Studio IDE, the UI will be shown and any messages are shown in the console window.


Parameter Description
 ShowUI shows the user interface (and populates any other provided parameters into the interface).  If this parameter is omitted, then the OOF settings will be updated based upon the other parameters.
 Replace when in none-UI mode, this forces the OOF settings to be overridden even if already enabled (by default, if OOF is enabled, settings won’t be changed). 
 EWSUrl specify the URL used for EWS requests (if omitted, autodiscover is used to determine the URL). 
 Username specify the username to be used for EWS requests (if omitted, the credentials of the logged in user will be used). 
 Password specify the user account password. 
 Domain specify the domain for user credentials (usually won’t be necessary). 
 Mailbox specify the SMTP address of the mailbox to be accessed. 
 Impersonate use EWS impersonation to access the mailbox.  Impersonation rights must have been granted to the authenticating user.  This option can be used so that multiple mailboxes can be processed by one user. 
 IgnoreSSLCertificate ignore SSL certificate errors
 OOFState specify the OOF state, which can be one of disabled, enabled, or scheduled. 
 OOFStart if scheduled OOF, this specifies the start date/time for the OOF period. 
 OOFEnd if scheduled OOF, this specifies the end date/time for the OOF period (the point at which OOF will be turned off). 
 InternalMessage specify the text file containing the internal OOF message to be applied (can be HTML) 
 ExternalMessage specify the text file containing the external OOF message to be applied (can be HTML) 



 Set the OOF messages, but leave other settings (e.g. OOF state) unchanged (no changes are made if OOF is currently enabled or scheduled):

SetOOF mailbox:user1.ex2k10@hybrid.local internalmessage:”internal.txt” externalmessage:”external.txt”


Set of OOF messages, replacing any existing messages, and turn OOF on:

SetOOF mailbox:user1.ex2k10@hybrid.local internalmessage:”internal.txt” externalmessage:”external.txt” Replace OOFState:Enabled


If you use the ShowUI parameter, then a Windows form is displayed that allows you to read, edit, and save OOF settings manually.  Messages will be logged to the console window.  When run from the command-line, OOF will not be updated if it is already enabled on the mailbox (unless replace parameter is given), which means that this could be used in conjunction with some PowerShell (e.g. Get-Mailbox) to process lots of mailboxes and only update ones with OOF disabled.  The UI looks like this:


Please rate this


1 thought on “EWS: Update Out-of-Office (OOF) sample application

Leave a Reply

Your email address will not be published. Required fields are marked *