Users often forget to maintain their out-of-office note in Outlook when they are on vacation, for example. A possible solution would be to automatically enter the out-of-office note if a central calendar is maintained that users invite when they are on vacation.
I have created a small script that queries a calendar via EWS and creates a corresponding note if the absence note is not set. You need the EWS Managed API for the script:
http://www.microsoft.com/en-us/download/details.aspx?id=35371&WT.mc_id=rss_alldownloads_all
and a resource mailbox (for example with the name "vacation calendar"). The script can simply be run every morning at 06:00 using task scheduling.
The user who executes the script requires the appropriate rights to create absence notes, as well as the following rights on the calendar of the absence calendar:
The users must then invite the vacation calendar as a resource to their appointment entry in Outlook. Here is the script.
#-----------------------------
# Create automated out-of-office messages
# www.frankysweb.de
#
# by Frank Zöchling
# Version 0.1
#
#-----------------------------$mailboxName = „urlaub@frankysweb.de“
#EWS Establish connection
Add-Type -Path „C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll“
$version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
$service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService($version)
$service.UseDefaultCredentials = $true
$service.AutodiscoverUrl($mailboxName)#Get calendar data
$Propset = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties)
$folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Calendar, $mailboxName)
$calendarFolder = [Microsoft.Exchange.WebServices.Data.calendarFolder]::Bind($service, $folderid)
$calendarView = new-object Microsoft.Exchange.WebServices.Data.CalendarView([System.DateTime]::Now, [System.DateTime]::Now.AddDays(0))
$Calendarview.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet($Propset)
$calendarView.MaxItemsReturned = 200;
$resultlist = $calendarFolder.FindAppointments($calendarView)
$resultlist.load($Propset)#Process calendar and activate OOF
foreach ($result in $resultlist)
{
$person = $result.Organizer
$mail = $person.Address
$name = $person.name
$urlaubstart = $result.Start
$vacation end = $result.End
$start = $vacation start
$ende = $urlaubende
$vacation end = $vacation end.AddDays(1)
$vacation end = $vacation end | get-date -format dd.MM.yyyy
$vacation start = $vacation start | get-date -format dd.MM.yyyy$status = Get-MailboxAutoReplyConfiguration -Identity $mail
$status = $status.AutoReplyStateif ($status -match „Disabled“)
{# Enter text for the external message here:
$txtextern = “<html>
<body>
Ladies and Gentlemen, <br>
I am currently out of the office. You can reach me again as usual from the end of the 1TP4 vacation. <br>
With kind regards, <br>
$name
</body>
</html>"
#Here Enter text for the internal message:
$txtintern = “<html>
<body>
Hello colleagues, I am on vacation and will be back at the end of my 1TP4 vacation. <br>
$name
</body>
</html>"
$autoreply = Set-MailboxAutoReplyConfiguration -Identity $mail -StartTime $start -EndTime $ende -AutoReplyState Scheduled -ExternalMessage $txtextern -InternalMessage $txtintern
}
}