Solved

Deploy rule for Outlook 2010

Posted on 2014-01-22
17
2,191 Views
Last Modified: 2016-02-11
We have 50+ users who use a particular application that sends emails on their behalf over SMTP. The application can be configured to bcc any emails sent to the sender.

I want to create rule that will move any emails sent from themselves to themselves (bcc) to be moved to their sent items.
However I do not want to go to every computer one by one to set this up.

Is there a way I can deploy a rule to all computer via Group Policy or in Exchange?

We're using Windows 7 Pro, Outlook 2010 and Exchange 2010 on Server 2008 R2 server.
0
Comment
Question by:antonioking
17 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 39801174
Hi, antonioking.

I'm not a group policy expert.  That said, I'm not aware of any way to deploy a rule through group policy.  However, you can create a rule via a script, so if your office uses a logon script or if a script can be pushed via a group policy, then you could do this.  If that's possible, then I can help with the script.  I'm afraid I can't help with the group policy aspect.
0
 

Author Comment

by:antonioking
ID: 39802377
Hi BlueDevilFan
A script sounds good. We do use logon scripts where group policy can't fulfill our needs.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 39802684
antonioking,

Here is the script.  It creates a rule that moves all message sent from the user's email address to the Sent Items folder except if the user's email address is in the To or CC line.  That's the only way I know of to catch BCCs since there is no rule action for BCC'd messages.  I tested the script on my computer (Win7/Office 2013) and it worked perfectly.  It should work on Office 2010 just as well.  Note that the script must run under the user's credentials to work properly.

Please give it a try and let me know if that's what you needed.

'On the next line, edit the name of the rule as desired
Const RULE_NAME = "Move BCC msgs to myself to Sent Items"
Const olRuleReceive = 0
Const olFolderSentMail = 5
Dim olkApp, olkSes, olkCol, olkRul, olkCD1, olkCD2, olkMRA
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkCol = olkSes.DefaultStore.GetRules()
Set olkRul = olkCol.Create(RULE_NAME, olRuleReceive)
Set olkCD1 = olkRul.Conditions.From
With olkCD1
    .Enabled = True
    .Recipients.Add olkSes.CurrentUser.Address
    .Recipients.ResolveAll
End With
Set olkCD2 = olkRul.Exceptions.ToOrCc
With olkCD2
    .Enabled = True
End With
Set olkMRA = olkRul.Actions.MoveToFolder
With olkMRA
    .Enabled = True
    Set .Folder = olkSes.GetDefaultFolder(olFolderSentMail)
End With
olkCol.Save False
olkSes.Logoff
olkApp.Quit
Set olkMRA = Nothing
Set olkCD2 = Nothing
Set olkCD1 = Nothing
Set olkRul = Nothing
Set olkCol = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
WScript.Quit

Open in new window

0
 

Author Closing Comment

by:antonioking
ID: 39802703
Perfect.
Thanks!
0
 

Author Comment

by:antonioking
ID: 39802709
How can I stop the script from running once the rule has been created?
The rule duplicates itself everytime I logon.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39802742
I'll add code to check and see if the rule already exists and create it if it doesn't.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39802753
Here you go.  This version tests to see if the rule exists and only creates it if it doesn't.

Const RULE_NAME = "Move BCC msgs to myself to Sent Items"
Const olRuleReceive = 0
Const olFolderSentMail = 5
Dim olkApp, olkSes, olkCol, olkRul, olkCD1, olkCD2, olkMRA
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkCol = olkSes.DefaultStore.GetRules()
Set olkRul = olkCol.Item(RULE_NAME)
If Typename(olkRul) = "Nothing" Then
    Set olkRul = olkCol.Create(RULE_NAME, olRuleReceive)
    Set olkCD1 = olkRul.Conditions.From
    With olkCD1
        .Enabled = True
        .Recipients.Add olkSes.CurrentUser.Address
        .Recipients.ResolveAll
    End With
    Set olkCD2 = olkRul.Exceptions.ToOrCc
    With olkCD2
        .Enabled = True
    End With
    Set olkMRA = olkRul.Actions.MoveToFolder
    With olkMRA
        .Enabled = True
        Set .Folder = olkSes.GetDefaultFolder(olFolderSentMail)
    End With
    olkCol.Save False
End If
olkSes.Logoff
olkApp.Quit
Set olkMRA = Nothing
Set olkCD2 = Nothing
Set olkCD1 = Nothing
Set olkRul = Nothing
Set olkCol = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
WScript.Quit

Open in new window

0
 

Author Comment

by:antonioking
ID: 39802765
Thanks!
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 76

Expert Comment

by:David Lee
ID: 39802774
You're welcome!
0
 

Author Comment

by:antonioking
ID: 39806124
Hi BlueDevilFan
Wonder if you could help one an error..

Some users are getting the error

Line: 9
Char 1:
Error: The attempted operation failed. An object could not be found.

Why is this?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39806140
Add this command

On Error Resume Next

after line 4.
0
 

Author Comment

by:antonioking
ID: 39806158
Thanks! That's stopped the error, but the rule doesn't get created.
To reward you for your time, I have created a new question here...

Q_28347242
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39806489
Thanks, but there's no need for another question.  I shouldn't get extra points for a problem of my own making.

The problem is the test on line 10.  I sometimes forget the differences between VBA and VBScript.  In VBA Typename would return "Nothing" while in VBScript it returns "Empty".  Change "Nothing" to "Empty" on line 10 and you're in business.  Here's the corrected version for any future readers of this question.

Const RULE_NAME = "Move BCC msgs to myself to Sent Items"
Const olRuleReceive = 0
Const olFolderSentMail = 5
Dim olkApp, olkSes, olkCol, olkRul, olkCD1, olkCD2, olkMRA
On Error Resume Next
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkCol = olkSes.DefaultStore.GetRules()
Set olkRul = olkCol.Item(RULE_NAME)
Debug.Write TypeName(olkRul)
If Typename(olkRul) = "Empty" Then
    Set olkRul = olkCol.Create(RULE_NAME, olRuleReceive)
    Set olkCD1 = olkRul.Conditions.From
    With olkCD1
        .Enabled = True
        .Recipients.Add olkSes.CurrentUser.Address
        .Recipients.ResolveAll
    End With
    Set olkCD2 = olkRul.Exceptions.ToOrCc
    With olkCD2
        .Enabled = True
    End With
    Set olkMRA = olkRul.Actions.MoveToFolder
    With olkMRA
        .Enabled = True
        Set .Folder = olkSes.GetDefaultFolder(olFolderSentMail)
    End With
    olkCol.Save False
End If
olkSes.Logoff
olkApp.Quit
Set olkMRA = Nothing
Set olkCD2 = Nothing
Set olkCD1 = Nothing
Set olkRul = Nothing
Set olkCol = Nothing
Set olkSes = Nothing
Set olkApp = Nothing
WScript.Quit                                       

Open in new window

0
 

Author Comment

by:antonioking
ID: 39806510
Thanks BlueDevilFan!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 39806634
You're welcome.  Sorry for the problem.
0
 

Expert Comment

by:glenn_r
ID: 40689558
I've got a similar question re how to write a vb rule (rwz) for outlook that executes an external file. I've got this working as an rwz but need to deploy to 500 client machines. Was hoping to write a script to do this. I'm a dev but new to outlook/vba/scripting and need some directions. Can you give me some advice?
see
http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_28644021.html?anchor=a40688749
0
 
LVL 53

Expert Comment

by:McKnife
ID: 40805941
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't know how to downgrade, my instructions below should be helpful.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now