Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2665
  • Last Modified:

Deploy rule for Outlook 2010

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
antonioking
Asked:
antonioking
1 Solution
 
David LeeCommented:
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
 
antoniokingAuthor Commented:
Hi BlueDevilFan
A script sounds good. We do use logon scripts where group policy can't fulfill our needs.
0
 
David LeeCommented:
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
Technology Partners: 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!

 
antoniokingAuthor Commented:
Perfect.
Thanks!
0
 
antoniokingAuthor Commented:
How can I stop the script from running once the rule has been created?
The rule duplicates itself everytime I logon.
0
 
David LeeCommented:
I'll add code to check and see if the rule already exists and create it if it doesn't.
0
 
David LeeCommented:
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
 
antoniokingAuthor Commented:
Thanks!
0
 
David LeeCommented:
You're welcome!
0
 
antoniokingAuthor Commented:
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
 
David LeeCommented:
Add this command

On Error Resume Next

after line 4.
0
 
antoniokingAuthor Commented:
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
 
David LeeCommented:
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
 
antoniokingAuthor Commented:
Thanks BlueDevilFan!
0
 
David LeeCommented:
You're welcome.  Sorry for the problem.
0
 
glenn_rCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now