We have a staff member in sales who has gone onto a 4 day week (getting ready for retirement), so each Thursday afternoon her email needs to be forwarded to another user and each Friday afternoon it needs to be set back.
I'm using the VBS script below to do this, run via the Task Scheduler. Although the script appears to do it's job, based on what I see when I view the user's Exchange settings, Exchange doesn't always recognise that the setting has changed. e.g. Last Thursday the forwarding was a enabled and worked correctly. On Friday the script did it's thing to clear the forwarding but Exchange continued to forward messages all weekend.
I found that I can force Exchange to honour the changed setting be merely opening and closing the user's properties in ADUC. Of course I don't want to have to do that. Is there a non-manual way I can have Exchange read and honour the setting?
The script (VBS):
' Call this script with the following parameters:
'
' SrcUser - The logon ID of the suer who's account is to be modified
' DstUser - The logon account of the person to who mail is to be forwarded
' Use "reset" to clear the email forwarding
SrcUser = WScript.Arguments.Item(0)
DstUser = WScript.Arguments.Item(1)
SourceUser = SearchDistinguishedName(SrcUser) 'The user login name
Set objUser = GetObject("LDAP://" & SourceUser)
If DstUser = "reset" then
objUser.PutEx 1, "altRecipient", ""
Else
ForwardTo = SearchDistinguishedName(DstUser)' The contact common name
objUser.Put "AltRecipient", ForwardTo
End If
objUser.SetInfo
Public Function SearchDistinguishedName(ByVal vSAN)
Dim oRootDSE, oConnection, oCommand, oRecordSet
Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & ">;(&(objectCategory=User)(samAccountName=" & vSAN & "));distinguishedName;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function
Edit:
If someone has another way to achieve the same goal (scheduled forwarding and cancellation of same) I'm open to suggestions. Surely this need has been encountered and met before.
Update:
For reasons I won't even try to guess, without changing anything the script system has been working almost completely reliable for some time. Over the last 3 or 4 months it has only failed once.
Wouldn't it be easier (and kinder) to simply setup a shared "Sales" mailbox, let all the required salesdroids use it. Its never going to be as fast as a simple redirection, but there is no need to script it or anything then. (We use many here, allows users to change roles, get promoted, quit etc without having to worry about redirecting or informing customers of new addresses etc).
The other alternative (in Exchange) is a Public Folder, simply create & set permissions on it for all who will need access (using Outlook), then assign the email address[es] you require (in System Manager, will default to "[email protected]"), then all mail will go there instead.. has similar/familiar delegation controls/permissions etc. If particular users need access to shared calendars or mailboxes, they can set them as "Favorites".
That way, users can "Grab" messages for themselves, by moving them into their own mailbox, or deleting them when done etc.. Also, looks professional when you see: Joe Bloggs on Behalf of [email protected]. If its the public folder, turn of "Maintain Per user Read/unread information.." then staff can tell when a message has already been read by someone else.
Customers like it, they get an easy to remember address and, their messages aren't lost! (that is the biggie I think)
The managers like it, they can keep tabs on open items, weigh in on things and generally be "Managers".. ;-)
I think you may find that a less technical solution meets your needs.
Give permission to access the 4 day weekers mailbox to the person you would have forwarded their mail to.
You can set up the user account to send replies in their own name, on behalf of, or sent as the 4 day weeker.
Sure, you still have to make sure that the other member of staff checks the mailbox, which may be an issue if this is sales related.
Or you could just use Out of Office to forward the mail on to the appropriate member of staff. Your 4 dayer could then just switch on Out of Office every Thursday. She'll get prompted to switch it off when she logs back in. Once Out of Office is configured, it will have the same config each time she opens Outlook.
Again, it requires someone to take a manual action - but if she is that good, switching on Out of Office every Thursday before she leaves isn't that hard to remember (and you could set a Task with a reminder in Outlook for 4:30pm every Thursday).
It might also be easier to script switching on Out of Office, with whatever rules have already been configured for the user.