Click here to Skip to main content
12,405,543 members (60,034 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

3.6K views
2 bookmarked
Posted

Update Rules; Don't Miss Emails From Actual People!

, 14 Feb 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Update Rules With Exception on Reply and Forward

Introduction

I recently fell very far behind on a project, because I wasn't aware it had started until my boss asked me where I was on it. Come to find out that I was moving emails from services into a folder I had named "Daily Processes" and when a person in my group found an exception within a service, he replied to the email the service sent. An entire conversation with action items continued from that email and I never once knew a thing about the project to fix the service.

I decided I needed to either get rid of all my rules, which I had a LOT of, or figure out some way to get replies from these services in my main inbox folder. Well, I couldn't delete my rules because I get thousands of emails a week and I would be inundated again with emails that mean little to nothing to me. I knew there was an exception property to rules that could be set, but I didn't want to spend the time going through every single one of those rules. Plus, I wanted to see if it could be done through a macro.

Using the Code

You'll have to set up your Outlook to allow development, and you'll have to enable macros for a brief time. I do not recommend leaving this setting on, though. Once you have run the code, you may turn it back off if you choose to do so.

To enable macros: Go to File -> Options -> Trust Center -> Trust Center Settings -> Macro Settings -> Enable All Macros. For some reason, the change in the trust center didn’t register until I closed Outlook completely. You may have to do that as well if you’ve had Outlook open for days like I did.

To see the Developer tab: Click the File tab -> Click Options -> Click Customize Ribbon -> Under Customize the Ribbon and under Main Tabs, select the Developer check box. Now you should be able to get into the VB code part by going into the Developer tab and clicking the Visual Basic button (Alt+F11 for you hot-key gurus).

Add references: In the Visual Basic editor, go to Tools ->References -> Then add in the Visual basic For Applications and Microsoft Outlook 14.0 Object Library.

Copy in the code. I believe you can do this in the main window. You might have to double click on the ThisOutlookSession. Or you can add a new module, which is what I did. Personally, I like to have separate modules per macro.

Sub LoopThroughRulesAddSubjectExceptionForwardReply()
    Dim colRules As Outlook.Rules
    Dim oRule As Outlook.Rule
    Dim oExceptSubject As Outlook.TextRuleCondition
       
    'Get Rules from Session.DefaultStore object
    Set colRules = Application.Session.DefaultStore.GetRules()
    
    For i = 1 To colRules.Count
        'get a single rule
        Set oRule = colRules.Item(i)
        
        'get the exception on that rule
        Set oExceptSubject = oRule.Exceptions.Subject
        
        If Not oExceptSubject.Enabled Then
            oExceptSubject.Enabled = True
        End If
            
        If TypeName(oExceptSubject.Text) <> "String()" Then
            oExceptSubject.Text = Array("RE:", "FW:")
        End If
    Next
        
    colRules.Save
End Sub 

Press F5 and let it run.

Points of Interest

Remember that there is no really good way to reference a Reply of a Forward when it comes to rules. I simply chose the text "RE:" and "FW:" and hope that whoever is emailing me is using a system that also employs this standard.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

PopeDarren
Software Developer (Senior) MFA Oil
United States United States
I like puzzles, math, astronomy, books and movies and I read about 3 sci-fi books every month. I also love to laugh. I'm the guy who laughs out loud with headphones on. I know, most of you all hate that guy... but you try to watch this without laughing out loud: https://www.youtube.com/watch?v=JI1kq6CA_38

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160721.1 | Last Updated 15 Feb 2014
Article Copyright 2014 by PopeDarren
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid