?
Solved

Outlook 2007 rules import format or syntaxis

Posted on 2009-05-20
6
Medium Priority
?
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 1500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
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 …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

764 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