Very often it happens that a user leave for her holidays forgetting to set up a proper Out of Office automatic reply in her Outlook client, as you know PowerShell can be used to set Out of Office for a mailbox with the Set-MailboxAutoReplyConfiguration like this:
Set-MailboxAutoReplyConfiguration "HeloCheck" -AutoReplyState enabled -ExternalAudience all -InternalMessage "Thanks for your message I'll not be in the office today" -ExternalMessage "I'm not in the office please call my mobile for urgent matters"
What the above command will do is setting an automatic out of office reply with different messages depending if the sender is internal to the organization or an external sender, so far so good I’ve used a very simple message but what if I need to set up a longer and formatted message?
The cmdlet does not natively support HTML formatted messages or special key like line breaks but we can easily workaround this creating an out of office message in a text file which will then be used with the above command here’s an example:
Thanks for your message, I will not be in the office today. In urgent cases pelase call my mobile number Best Regards, Lethe.
Save the above text in a file named something like OoO.txt or whatever name you prefer, now all you have to do is read the content of the file via PowerShell and use it to with the Set-MailboxAutoReplyConfiguration like this:
$outMessage = Get-Content "C:OoO.txt" Set-MailboxAutoReplyConfiguration "HeloCheck" -AutoReplyState enabled -ExternalAudience all -InternalMessage $outMessage-ExternalMessage $outMessage
The above command will set the Out of Office on a permanent basis for the given mailbox, if you need to have PowerShell set Out of Office just for a definite period of time you would use the following command:
Set-MailboxAutoReplyConfiguration "HeloCheck" -AutoReplyState scheduled -ExternalAudience all -InternalMessage $outMessage-ExternalMessage $outMessage -StartTime "11/01/2014" -EndDate "11/15/2014"