Consulting

Results 1 to 4 of 4

Thread: Mail notifiction based on category

  1. #1

    Mail notifiction based on category

    Good afternoon.

    I have located a bit of code that produces a pop up message when an email is moved to a particular sub folder of a shared mailbox.

    This message pops up everytime an email is moved, however, I would like it to only pop up if the email is in a certain category.

    The code so far is (thanks to Steiner):


    Option Explicit
     
    Private Fold1 As Outlook.MAPIFolder
    Private WithEvents colItems1 As Outlook.Items
     
    Private Sub Application_Startup()
         'Insert the folder names here!
        Set Fold1 = Application.GetNamespace("MAPI").Folders("TECHNOLOGY ITD ITCS NEE Team").Folders("Inbox").Folders("Work In Progress")
        Set colItems1 = Fold1.Items
    End Sub
     
    Private Sub colItems1_ItemAdd(ByVal Item As Object)
        MsgBox "New mail from " & Item.SenderName & " in " & Fold1.Parent.Name
    End Sub
     
    Private Sub Application_Quit()
         'Clean Up
        Set Fold1 = Nothing
        Set colItems1 = Nothing
    End Sub

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Try this:

    Private Sub colItems1_ItemAdd(ByVal Item As Object)
        If Item.Categories = "test" Then
            MsgBox "New mail from " & Item.senderName & " in " & Fold1.Parent.name
        End If
    End Sub
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

  3. #3
    Quote Originally Posted by skatonni View Post
    Try this:

    Private Sub colItems1_ItemAdd(ByVal Item As Object)
        If Item.Categories = "test" Then
            MsgBox "New mail from " & Item.senderName & " in " & Fold1.Parent.name
        End If
    End Sub
    That works a treat - thank you

    Could this also be changed to give a pop up when an email is categorised in the main Inbox?

  4. #4
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Quote Originally Posted by kellyhell View Post
    Could this also be changed to give a pop up when an email is categorised in the main Inbox?
    Set Fold1 = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
    If not what you wanted, ask a new question with details.
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •