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

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

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

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
tdwhelp
Asked:
tdwhelp
  • 6
  • 4
1 Solution
 
David LeeCommented:
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
 
tdwhelpAuthor Commented:
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
 
David LeeCommented:
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
tdwhelpAuthor Commented:
RULE example:

emails from helpdesk@<domain>.com will get placed into a folder called "helpdesk" under INBOX.
0
 
David LeeCommented:
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
 
David LeeCommented:
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
 
tdwhelpAuthor Commented:
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
 
David LeeCommented:
M fault.  I left off part of the command on 40.  It should read

    Set .Folder = olkSes.GetDefaultFolder(olFolderInbox).Folders("HelpDesk")
0
 
tdwhelpAuthor Commented:
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
 
David LeeCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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