Link to home
Start Free TrialLog in
Avatar of MPAQUIN
MPAQUIN

asked on

Out of Office assistant script

I would like to set-up a script that turn the Out of Office assistant for someone,s else mailbox. The reason is some supervisor, when their employee don't come in, they often forget about setting their Out of Office and keep asking me to do it, so if I give them a small script it would ease the process.

ASKER CERTIFIED SOLUTION
Avatar of eshurak
eshurak
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Chromarty
Chromarty

Here is a VB script that uses CDO to manipulate OOF.  Works on a server with Exchange management tools installed and run as an account with full control over the target mailbox.

Dim mapiSession
Dim sMailbox
Dim sServer

strMailbox = "Username"
strServer = "ExServer"

Set mapiSession = CreateObject("MAPI.Session") mapiSession.Logon , , True, True, , , strServer & vbLf & strMailbox

If Err.Number = 0 Then
Wscript.Echo "Logged in!"
mapiSession.OutOfOffice = True
mapiSession.OutOfOfficeText = "I am out of Office."
Wscript.Echo  "OOF set!"
End If

mapiSession.Logoff
Set mapiSession = Nothing

Wscript.Echo "Logged off!"