Giter Club home page Giter Club logo

microsoft-outlook-auto-categorize's Introduction

Automatically Categorise Email on Microsoft Outlook

Automatically add category to incoming email or outgoing email based on

  • Sender,
  • Subject, or
  • Domain

Setup Steps:

Add VBA Project to Outlook

Create different files as showing in the image below

outlook-items

Enable Macros

You have to enable all macros as shown below

enable-macros

Modify per your need

Update Modules/AutoCategorized.vb file to fit your need

Public Sub AddSenders()
    Set KnownSenders = New Dictionary
    KnownSenders.Add "[email protected]", "Help"
    KnownSenders.Add "[email protected]", "DNR"
End Sub


Public Sub AddSubjectLines()
    Set KnownSubjectLines = New Dictionary
    KnownSubjectLines.Add "Subject line", "SL"
    
End Sub
   

Public Sub AddDomainNames()
    Set KnownDomains = New Dictionary
    KnownDomains.Add "twitter.com", "Tweet"
    KnownDomains.Add "gmail.com", "Gmail"
    
End Sub

Test it out

In this file, Modules/AutoCategorized.vb, you will find the section below. Click inside the Sub and Run (F5) it. You will notice the categories will be added Note: To see the colors on category, you have to restar the Outlook.

'' ****************************************
'' - - - - - - - - - - - - - - - - - - - -
''
'' TEST SUBS
''
'' - - - - - - - - - - - - - - - - - - - -
'' ****************************************

Public Sub ApplyCategoriesToAllInboxItems()
    Dim objNS As Outlook.NameSpace: Set objNS = GetNamespace("MAPI")
    Dim olFolder As Outlook.MAPIFolder
    Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
    Dim Item As Object
    
    ' Initialize the list of known doamin dictionary
    AddDomainNames
    
    ' Initialize the list of known subject lines
    AddSubjectLines
    
    ' Initialize the list of the know senders list
    AddSenders
    
    For Each Item In olFolder.Items
        If Item.Class = olMail _
        Or Item.Class = olMeetingReceived Then
        
            OutlookItemReceivedOrSent Item
        End If
    Next
    
    MsgBox "Done"
End Sub

Restart Outlook

Once above two setps are done, restart outlook.

Run PowerShell when conditions are right

If you need to do some external work based on the email you received or sent, you can do something like below to automate

Public Sub RunPowerSheelToInstallApplications(emailAddresses As Collection, emailItem As Object)
    Dim email As Variant
    For Each email In emailAddresses
        Dim emailAddress As String: emailAddress = CStr(email)
        If ValidEmail(emailAddress) _
            And emailAddress = "[email protected]" _
            And InStr(emailItem.Subject, "SubjectContains") Then
        
            'Run power shell
            Dim ps As Variant
            ps = Shell("POWERSHELL.exe -noexit " & _
                  """D:\..\..\PowerShell\MyPowerShell.ps1""", 1)
            
        End If
    Next
        
End Sub

microsoft-outlook-auto-categorize's People

Contributors

worthapenny avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.