Solved

Centrally manager folder creation and server-side rules for outlook 2007 users mailboxes

Posted on 2011-03-08
12
486 Views
Last Modified: 2013-11-05
We run exchange 2007 with outlook 2007 clients and need to centrally create and manage server-side rules for users and to also create specific folders under their INBOX.

Can this be done without having to setup the server-side rules and create the folders locally at each outlook 2007 client?
0
Comment
Question by:tdwhelp
  • 6
  • 4
12 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 35078631
Hi, tdwhelp.

I am not enough of an Exchange expert to know if it is possible to do this at the server.  Depending on the rules I can probably do it at the client via a script.  I know I can create the folders via a script at the client.
0
 

Author Comment

by:tdwhelp
ID: 35083328
IF Exchange can centrally manage that, I would certainly prefer it.  

But a script would be helpful if that is possibility as well, as plan B.  Do you have an example of it?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35083434
I have an example of creating folders.  I'd need to put one together for creating rules.  I don't mind doing that.  The script will be more useful if you can give me an example of what you'd like a rule to do.  There are lots of variations on rules, so a sample I put together blindly may not be of much value to you.
0
 

Author Comment

by:tdwhelp
ID: 35087500
RULE example:

emails from helpdesk@<domain>.com will get placed into a folder called "helpdesk" under INBOX.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35088907
This should do it.  This script will only work in Outlook 2007 and 2010.  It demonstrates how to create a folder and how to create a rule.  Follow these instructions to use it.

1.  Open Notepad
2.  Copy the code and paste it into Notepad
3.  Edit the code per the comments I included in it
4.  Save to a .vbs file

To test the code simply double-click the saved .vbs file.

You can include this code in a logon script or run it from a group policy.  Either approach will allow you to add folders and rules centrally.  The script could even be enhanced to check for the existence of certain rules/folders and create them if they are missing.  
'Define some constants'
	Const olFolderInbox = 6
	Const olRuleReceive = 0

'Define some variables'
	Dim olkApp, olkSes, olkFld, olkAll, olkRul, olkCon, olkAct
	
'Connect to Outlook'
	Set olkApp = CreateObject("Outlook.Application")
	Set olkSes = olkApp.GetNamespace("MAPI")
	olkSes.Logon olkApp.DefaultProfileName

'Add a folder under the Inbox'
	'Repeat the next line for each folder you want to add.  Change the folder name on the next line.'
	olkSes.GetDefaultFolder(olFolderInbox).Folders.Add("Some Name")

'Create a rule.  Repeat this block of code (down to but not including Clean up) for each rule you want to add.'
	
	'Get the exiting rules'
	Set olkAll = olkSes.DefaultStore.GetRules
	
	'Add a new rule'
	'Change the rle name on teh next line'
	Set olkRul = olkAll.Create("Rule Name", olRuleReceive)
	
	'Create the rule condition'
	Set olkCon = olkRul.Conditions.From
	With olkCon
		.Enabled = True
		'Change the email address on the next line'
		.Recipients.Add "helpdesk@domain.com"
		.Recipients.ResolveAll
	End With

	'Create the rule action'
	Set olkAct = olkRul.Actions.MoveToFolder
	With olkAct
		.Enabled = True
		'Change the folder name on the next line'
		.Folder = olkSes.GetDefaultFolder(olFolderInbox).Folders("HelpDesk")
	End With
	
	'Save the new rule'
	olkAll.Save True

'Clean up'
	olkSes.Logoff
	Set olkAct = Nothing
	Set olkCon = Nothing
	Set olkRul = Nothing
	Set olkAll = Nothing
	Set olkFld = Nothing
	Set olkSes = Nothing
	Set olkApp = Nothing

Open in new window

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
ID: 35088940
I should have added that a rule is either server side or client side based on how it works.  Certain conditions and actions only work at the client.  The rule you gave should be a server side rule.
0
 

Author Comment

by:tdwhelp
ID: 35099150
Blue Devil Fan,

Thank you for your script, it creates the folder but errors out at line 44 character 2.  It can't save because "one or more rules cannot be saved because of invalid actions or conditions".

any ideas?  my rule being named "helpdesk" inside the VB script.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35099243
M fault.  I left off part of the command on 40.  It should read

    Set .Folder = olkSes.GetDefaultFolder(olFolderInbox).Folders("HelpDesk")
0
 

Author Comment

by:tdwhelp
ID: 35139876
BlueDevilFan:

can we modify the vb script so it ONLY creates a rule that where the condition is "sent to people or distribution list" such as the helpdesk@domain.com?  I think this rule condition may be a better fit.

What I now think may work better, is that I set the helpdesk mailbox so it copies a group of IT staff on messages send to the helpdesk mailbox, then when that message arrives at the IT staff mailbox, "helpdesk@domain.com" will be in the TO: or CC: line and the email will get filtered by that and directed into the "helpdesk" folder that your vb script created.

0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 35142540
Sure.  Try this.  Replace the code you have now with the version below.
'Define some constants'
    Const olFolderInbox = 6
    Const olRuleReceive = 0

'Define some variables'
    Dim olkApp, olkSes, olkFld, olkAll, olkRul, olkCon, olkAct
    
'Connect to Outlook'
    Set olkApp = CreateObject("Outlook.Application")
    Set olkSes = olkApp.GetNamespace("MAPI")
    olkSes.Logon olkApp.DefaultProfileName

'Add a folder under the Inbox'
    'Repeat the next line for each folder you want to add.  Change the folder name on the next line.'
    olkSes.GetDefaultFolder(olFolderInbox).Folders.Add ("Some Name")

'Create a rule.  Repeat this block of code (down to but not including Clean up) for each rule you want to add.'
    
    'Get the exiting rules'
    Set olkAll = olkSes.DefaultStore.GetRules
    
    'Add a new rule'
    'Change the rule name on the next line'
    Set olkRul = olkAll.Create("Rule Name", olRuleReceive)
    
    'Create the rule condition'
    Set olkCon = olkRul.Conditions.SentTo
    With olkCon
        .Enabled = True
        'Change the email address on the next line'
        .Recipients.Add "helpdesk@domain.com"
        .Recipients.ResolveAll
    End With

    'Create the rule action'
    Set olkAct = olkRul.Actions.MoveToFolder
    With olkAct
        .Enabled = True
        'Change the folder name on the next line'
        Set .Folder = olkSes.GetDefaultFolder(olFolderInbox).Folders("HelpDesk")
    End With
    
    'Save the new rule'
    olkAll.Save True

'Clean up'
    olkSes.Logoff
    Set olkAct = Nothing
    Set olkCon = Nothing
    Set olkRul = Nothing
    Set olkAll = Nothing
    Set olkFld = Nothing
    Set olkSes = Nothing
    Set olkApp = Nothing

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
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 …
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…

744 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

10 Experts available now in Live!

Get 1:1 Help Now