PDA

View Full Version : Mail notifiction based on category



kellyhell
11-09-2015, 07:55 AM
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

skatonni
11-09-2015, 01:50 PM
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

kellyhell
11-11-2015, 07:31 AM
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?

skatonni
11-13-2015, 03:23 PM
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.