How to detect flag event from vba?

  • Thread starter Thread starter yajiv.vijay
  • Start date Start date
Y

yajiv.vijay

I want to move a message to a specified folder once its flagged. How
can I detect that flagging event from vba?
 
You'd have to handle the ItemChange event of the Items collection and check
to see what was changed. An alternative would be to instantiate event
handlers for any selected or open item and handle the item.PropertyChange
event but that wouldn't get you items flagged from the context menu since
those might not be selected.
 
I dont see any itemchange event in thisoutlooksession. Can you
explain with example?
 
It's the ItemChange event of the Items collection of the folder, as I said
originally. Look in the Object Browser for the Items collection and look at
its events.
 
It's the ItemChange event of the Items collection of the folder, as I said
originally. Look in the Object Browser for the Items collection and look at
its events.








- Show quoted text -

I just don't get how to activate that event. for example i want to
show a message box once a mail is flagged.
can you show me how?
 
Well, you didn't mention what types of items were being flagged or in what
folder or folders, but this would work for mail items in the Inbox. This
code would be in ThisOutlookSession:

Dim WithEvents colItems As Outlook.Items
Dim oFolder As Outlook.MAPIFolder

Private Sub Application_Startup()
Dim oNS As Outlook.NameSpace

Set oNS = Application.GetNameSpace("MAPI")
Set oFolder = oNS.GetDefaultFolder(olFolderInbox)
Set colItems = oFolder.Items
End Sub

Private Sub colItems_ItemChange(Item As Object)
If Item.FlagStatus = OlFlagStatus.olFlagMarked Then
' show MsgBox here or whatever
End If
End Sub




<snip>
I just don't get how to activate that event. for example i want to
show a message box once a mail is flagged.
can you show me how?
 
Back
Top