Solved

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

Posted on 2011-03-08
12
489 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

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.

Question has a verified solution.

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

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

775 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