VBScript ; Enable Out-Of-Office (OOO)

VBScript ; Enable Out-Of-Office (OOO)

The following script will allow you to enable Out Of Office on any users mailbox (provided you have permissions that it…)

Set objMAPISession = CreateObject(“MAPI.Session”)

‘strExchangeSvr = InputBox(“Please provide the name of your Exchange Server”)
strExchangeSvr = “mailserver-name”

strMailbox = InputBox(“Please enter the mailbox name to enable Out-Of-Office…”)

strMAPI = strExchangeSvr & vbLf & strMailbox

On error Resume Next

objMAPISession.Logon “”, “”, False, True, 0, False, strMAPI

If err <> 0 Then
Wscript.Echo “An Error occured: ” & err.description
Err.clear
Wscript.Sleep 7000
Wscript.Quit
End If

strOOOMessage = InputBox(“Please enter Out-Of-Office message…”)

objMAPISession.OutOfOfficeText = strOOOMessage
objMAPISession.OutOfOffice = 1
strOOOMessage = objMAPISession.OutOfOfficeText

objMAPISession.Logoff
Set objMAPISession = Nothing
MsgBox “All done”