Solved

Outlook 2007 rules import format or syntaxis

Posted on 2009-05-20
6
341 Views
Last Modified: 2012-05-07
Hi,

I have Outlook 2007 we certain rules. I would like to delete them all and start from scratch. The idea is that e-mails sent or received with a certain domain be movedo to a certain folder or e-mails to or from a certain e-mail address be sent to a subfolder.

I would like to know if this is possible to create the rules using an editor (text or similar) to create the rules. If so I need the syntaxis to use or the rule export format that then could be imported into Outlook. Also how to import those rules into Outlook.

TIA

0
Comment
Question by:moose25
  • 4
  • 2
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24430997
Hi, moose25.

"I would like to know if this is possible to create the rules using an editor (text or similar) to create the rules."
No, that's not possible.  You have two options.  One, create the rules using the Outlook GUI.  Two, write a script that creates the rules.  Why would you want to create the rules using a text editor?  How would that be simpler or better than creating them using Outlook's rules wizard?
0
 

Author Comment

by:moose25
ID: 24432144
Wizard is slow. also when sending an e-mail I would like to have it moved to a folder not to have a copy of it in it. This way porting rules would also be simpler.

Perhaps a script woul do it. Any examples in how to do it?
Basically the rules would be
Incoming e-mails:
 a) any e-mail with sender =@domain_of_sender.whatever MOVE it to folder Domain_of_server or any other name we might consider
  b) any e-mail with sender name@whatever.whatever MOVE it to folder or subfolder "whatever" or any other name we might consider


Outgoing e-mails
   a) any e-mail sent to=@domain_of_sender.whatever MOVE it to folder Domain_of_server or any other name we might consider
   b) any e-mail sent to name@whatever.whatever MOVE it to folder or subfolder "whatever" or any other name we might consider


TIA

Regards


0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24459180
"Wizard is slow"
Perhaps.  It's still probably faster than writing code to make a rule.  The code in the snippet is what's required to create the first of the four rules you mentioned.  

"I would like to have it moved to a folder not to have a copy of it in it"
Creating rules via scripting does not add to the list of actions you can take on a message.  They're the same.  The wizard doesn't offer the ability to move the item, so it cannot be done by creating the rule via scripting.

"This way porting rules would also be simpler"
True.

Continued in the next post.
Sub CreateRule1()

    Dim olkRules As Outlook.Rules, _

        olkRule As Outlook.Rule, _

        olkCondition As Outlook.AddressRuleCondition, _

        olkAction As Outlook.MoveOrCopyRuleAction

    Set olkRules = Outlook.Application.Session.DefaultStore.GetRules()

    Set olkRule = olkRules.Create("Rule 1", olRuleReceive)

    With olkRule

        'Create the condition'

        Set olkCondition = .Conditions.SenderAddress

        olkCondition.Address = Array("@domain_of_sender.whatever")

        olkCondition.Enabled = True

        'Create the action taken if the condition is true'

        Set olkAction = .Actions.MoveToFolder

        olkAction.Folder = OpenOutlookFolder("Personal Folders\Testing")

        olkAction.Enabled = True

    End With

    olkRules.Save

    Set olkAction = Nothing

    Set olkCondition = Nothing

    Set olkRule = Nothing

    Set olkRules = Nothing

End Sub

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

Assisted Solution

by:David Lee
David Lee earned 500 total points
ID: 24459208
Rules may not be the solution.  We can emulate the behavior of rules using code.  For example, the code in the snippet will handle both of the sending conditions.  You could add additional conditions by simply adding a new IF ... THEN and a new CASE statement.  There's is some supporting code I haven't included so you can make a direct comparison between the two approaches.  That support code is required for both.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

    Dim olkRecipient As Outlook.Recipient, intAction As Integer

    If Item.Class = olMail Then

        For Each olkRecipient In Item.Recipients

            If InStr(1, LCase(olkRecipient.Address), "@domain_of_sender.whatever") Then

                intAction = 1

                Exit For

            End If

            If InStr(1, LCase(olkRecipient.Address), "name@whatever.whatever") Then

                intAction = 2

                Exit For

            End If

        Next

        Select Case intAction

            Case 1  '<-- Match on domain name'

                Item.SaveSentMessageFolder = OpenOutlookFolder("Mailbox - Doe, John\Messages to domain_of_sender.whatever")

            Case 2  '<-- Match on addressee name'

                Item.SaveSentMessageFolder = OpenOutlookFolder("Mailbox - Doe, John\Messages to name@whatever.whatever")

        End Select

        Item.Save

    End If

End Sub

Open in new window

0
 

Author Comment

by:moose25
ID: 24462636
thanks
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24483493
You're welcome.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

17 Experts available now in Live!

Get 1:1 Help Now