none
Outlook 2003 VBA - is there an easy way to monitor multiple folders RRS feed

  • Question

  • Hi,

    I like to monitor (entries in a database each time) the life cycle of incoming mails in a specific use case. Two things are happening to these MailItems:

    - they are move around between several folders (like: "to be dispatched". "Assigned to ....". "Done")

    - subject line gets changed

    The list of folders to be monitored should be read out of a database, is there an easy way to achieve this?

    Thx

    Bernie

    Saturday, March 3, 2012 9:56 PM

Answers

  • Dim WithEvents folder_items As Items
    
    Sub sample()
    'read values of folders from db, let's assume those are entryids
    Set folder_items = ThisOutlookSession.Session.GetFolderFromID(EntryID).Items
    End Sub
    
    Private Sub folder_items_ItemAdd(ByVal Item As Object)
    
    End Sub
    
    Private Sub folder_items_ItemChange(ByVal Item As Object)
    
    End Sub
    
    Private Sub folder_items_ItemRemove()
    
    End Sub

    • Marked as answer by bhohenbild Tuesday, March 6, 2012 10:04 AM
    Tuesday, March 6, 2012 9:48 AM
  • i am very weak with VBA but there are articles about this, example: http://siddharthrout.wordpress.com/2011/08/05/vba-control-arrays/ 
    • Marked as answer by bhohenbild Thursday, March 8, 2012 8:05 AM
    Tuesday, March 6, 2012 11:39 AM

All replies

  • Hi Bernie,

    Thanks for posting in the MSDN Forum.

    I think I can't catch your goal. As Outlook is only a client of e-mail system. It means that it will on monitor the data for specific account which on your Outlook. And you have no right to monitor other accounts' action on your Outlook. I think it will make no sense to discuss this kind of issue in Outlook develop forum. If I have misunderstood anything, please feel free to let me know.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 5, 2012 6:16 AM
    Moderator
  • Hi Tom,

    thx for looking on this. Actually it's my own account (where others have access to), so it is ok from a legal point of view to monitor it. I also "just" try to record the "flow" of the mailitems between folders...

    Any help much appreciated.

    Have a good day too

    Bernie

    Monday, March 5, 2012 7:55 AM
  • It depends on what you consider easy - each time outlook starts you need to read either paths or entryids for folders that you want to monitor, find for each entry corresponding folder (either getfolderbyid or iterating and checking path property) and for matching folders you have to store somewhere Items objects (WithEvents declaration) and monitor events like ItemAdd, ItemRemove and ItemChange
    Monday, March 5, 2012 10:00 AM
  • Hi Bernie,

    I think what DamianD said is right.

    @DamianD,

    Thanks for you great working. Would you please show some simple sample to Bernie?

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, March 6, 2012 4:11 AM
    Moderator
  • Dim WithEvents folder_items As Items
    
    Sub sample()
    'read values of folders from db, let's assume those are entryids
    Set folder_items = ThisOutlookSession.Session.GetFolderFromID(EntryID).Items
    End Sub
    
    Private Sub folder_items_ItemAdd(ByVal Item As Object)
    
    End Sub
    
    Private Sub folder_items_ItemChange(ByVal Item As Object)
    
    End Sub
    
    Private Sub folder_items_ItemRemove()
    
    End Sub

    • Marked as answer by bhohenbild Tuesday, March 6, 2012 10:04 AM
    Tuesday, March 6, 2012 9:48 AM
  • @DamianD: many thanks, much appreciated

    is there a "smart" way to do this once for several folders (I only need the ItemAdd) in a generic way?

    Tuesday, March 6, 2012 10:16 AM
  • i am very weak with VBA but there are articles about this, example: http://siddharthrout.wordpress.com/2011/08/05/vba-control-arrays/ 
    • Marked as answer by bhohenbild Thursday, March 8, 2012 8:05 AM
    Tuesday, March 6, 2012 11:39 AM