Tips & Tricks - Microsoft Exchange - Setting Up an Out-of-Office Message

This article shows how to use the Microsoft Exchange Connector to create and enable an out-of-office message for an Exchange user account. You can download the sample application here and import it as usual. Enable the advanced options so that all the dialog boxes mentioned in this example are accessible. In addition, a connection to Microsoft Exchange must be set up.

On the "Overview" home page of the sample application, you'll find the "Static Text" element. In the Properties dialog, the following script is available on the "General" tab:

            #set($bIsEnabled = $ExchangeMailboxCallable.isOutOfOfficeEnabled())
#if($bIsEnabled)
Out of office message enabled
#else
Out of office message not activated
#end

        

On the "Options" tab, the "Programming, Standard Language Only" option is selected. The script is thus executed when the page loads in the browser and returns whether the out-of-office message is enabled or not.

On the "Change Status" page, you can enter the text of the out-of-office message in your browser. You'll also find the "Active" checkbox here. Neither input element requires a data field link.

A VM file named "outOfOffice.vm" was created on the page using the "VTL Include" element. The file contains the following script:

            $!ExchangeMailboxCallable.setOutOfOfficeMessage($Request.get('rq_message'))
#if($Request.get('rq_enabled') == "1")
	#set($bEnabled = true)
#else
	#set($bEnabled = false)
#end
$!ExchangeMailboxCallable.setOutOfOffice($bEnabled)
{
	"bReturn": true
}

        

The VTL include element was subsequently deleted because it is not strictly necessary.

The script can be edited later via the application node. To do this, select "Details" from the context menu. In the Details dialog box, click the "Open Temporary Working Directory" link. The VM file "outOfOffice.vm" is located in the "resources" folder.

On the "Change Status" page, you'll also find the "Apply" button, which links to the "Change Status" page. The "Change Status" page will load after you click the button. The following script is stored on the "Script" tab:

            function setOutOfOfficeMessage(p_oHtml) 
{
	/*Out of office message  textareacontrol*/
	var strMessage = Browser.getValue(getElement("GUID_TEXTFIELD")); 

	/*Active  checkcontrol*/
	var bEnabled   = Browser.getValue(getElement("GUID_CHECKBOX")); 

	var oAjax = new upSimpleAjax();
	oAjax.oFup = ContainerAgent.getFuncPart(p_oHtml);
	oAjax.oHtmlForm = oAjax.oFup.oForm.oHtml; 
	oAjax.oProcessFunc = function (p_oJSON) {

		if(!p_oJSON.bReturn)
		{
			alert("Error setting message.");
		}
		else
		{
			alert("Message set.");
		}
	}

	oAjax.bAsync = true;
	oAjax.bAddHistory = false;
	oAjax.loadAppSnippetJsonVm("internal/application/resource/0A3832BBDDECE6DA29F712724BF368B70B228711/outOfOffice.vm", {rq_message: strMessage, rq_enabled: bEnabled});

	return true;
}

        

If you want to use the script in other applications, you'll need to adjust the following values:

  • getElement("GUID_TEXTFIELD")
    GUID of the "Out-of-Office Message" text field

  • getElement("GUID_CHECKBOX")
    GUID of the "Active" checkbox

  • 0A3832BBDDECE6DA29F712724BF368B70B228711/outOfOffice.vm Replace 0A3832BBDDECE6DA29F712724BF368B70B228711 with the GUID of the current application.

All GUIDS can be identified directly in the editor in the "Application Structure" section. This function calls and executes the stored VM script via an AJAX call. The script is assigned to the button's onclick event with the "this" parameter. So it runs in the browser when you click the button.

The first time you open the application in your browser, you'll need to enter your Exchange login credentials and sign in. You can then enable the out-of-office message on the "Change Status" page. Once you've imported the message, it will be active in your Exchange mailbox immediately.