Solved

Deploy rule for Outlook 2010

Posted on 2014-01-22
17
2,126 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Perfect.
Thanks!
0
 

Author Comment

by:antonioking
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 76

Expert Comment

by:David Lee
Comment Utility
You're welcome!
0
 

Author Comment

by:antonioking
Comment Utility
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
Comment Utility
Add this command

On Error Resume Next

after line 4.
0
 

Author Comment

by:antonioking
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks BlueDevilFan!
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
You're welcome.  Sorry for the problem.
0
 

Expert Comment

by:glenn_r
Comment Utility
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
Comment Utility
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
Outlook Free & Paid Tools
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

8 Experts available now in Live!

Get 1:1 Help Now