Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Deploy rule for Outlook 2010

Posted on 2014-01-22
17
Medium Priority
?
2,590 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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
 
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 56

Expert Comment

by:McKnife
ID: 40805941
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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