Tips & Tricks - Microsoft Exchange - Set out-of-office message
This article shows how to create and activate an out-of-office message for an Exchange user account using the Connector for Microsoft Exchange. You can download the sample application here and import it as usual. Activate the expert options so that all dialogs mentioned in this example are accessible. A connection to Microsoft Exchange must also be set up.
On the "Overview" start page, you will find the "Static text" element in the sample application. The following script is available on the "General" tab in the properties dialog:
#set($bIsEnabled = $ExchangeMailboxCallable.isOutOfOfficeEnabled())
#if($bIsEnabled)
Out of office message enabled
#else
Out of office message not activated
#end
The "Programming, default language only" option is selected on the "Options" tab. The script is performed when the page is loaded in the browser and states whether an out of office message has been activated or not.
The text of the out-of-office message can be entered in the browser on the "Change status" page. You will also find the "Active" checkbox here. Neither input element requires a data field link.
A VM file with the name "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 deleted afterwards as it is no longer necessary.
The script can be subsequently edited via the application node. To do this, select the "Details" context menu. Click on the "Open temporary working directory" link in the Details dialog. The VM file ""outOfOffice.vm"" is located in the "resources" folder.
On the "Change status" page, you will also find the "Apply" button with the jump target "Change status". The "Change status" page is therefore loaded after clicking on 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, the following values must be adjusted:
-
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 your application.
All GUIDS can be determined directly in the editor in the "Application structure" area. With the aid of this function, the defined VM script is called and performed via an AJAX call. The script is assigned to the onclick event of the button with the parameter "this". This means it is performed when the user clicks on the button in the browser.
When you open the application for the first time in the browser, you need to enter you Exchange login information and log in. You can then activate the out-of-office message on the "Change status" page. Once the message has been applied, it is immediately activated in your Exchange inbox.