none
Monitor Outlook Sub Folders RRS feed

  • Question

  • Hello,

    In Outlook, assume I have the following folders set up..

    --Outlook Mailbox "Inbox"

    -->Sub Folder for employee 1 "Victor Frankenstein"

    -->Sub Folder for employee 2 "Herman Munster"

    -->Sub Folder for employee 3"Igor Stravinsky"

    Is it possible to put a handler on each sub folder in order to monitor items moving into and out of each folder?  Keep in mind that the sub folders are dynamic.  What I mean by that is the number and names of sub folders can vary from week to week (high employee turnover).  

    Thanks for any advice you have!  (VB.NET or C#)


    • Edited by HokieMark Monday, November 10, 2014 5:09 PM Added language preference
    • Moved by KareninstructorMVP Monday, November 10, 2014 7:33 PM Moved from VB.NET forum
    Monday, November 10, 2014 4:34 PM

Answers

  • The Outlook object model is common for all kind of applications. The code will be the same.

    Take a look at the events of the Items class. For example, a raw sketch:


    folder.Items.ItemAdd+=yourHandler;
    Tuesday, November 11, 2014 2:45 PM
  • Hi HokieMark,

    Have you fixed this issue now? We can use Items.ItemAdd to monitor items add for the specific folder. And if you want to add this event for the folder dynamically, we can use Folders.FolderAdd Event to achieve the goal.

    Every time we add folder in Outlook, we can add ItemAdd event for the specific folder.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 18, 2014 10:18 AM
    Moderator

All replies

  • Hello,

    I would suggest moving this thread to a more appropriate forum which either myself or another moderator can do if you would like to have this question moved to an Outlook for developer's forum.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Monday, November 10, 2014 4:43 PM
  • Yes Please.  I appreciate that!
    Monday, November 10, 2014 5:10 PM
  • Yes Please.  I appreciate that!

    There may be some code in this blog that can assist you. Or maybe not. I would guess once you have folder paths you could use a filesystemwatcher on them but don't know for certain.

    How to develop Outlook 2010, 2007, 2003 add-in: Outlook objects and events

    This link may be helpful and the code is way down the page. It looks to me like VB.Net and not VB6.

    Get the Name of all SubFolders for an Outlook Folder


    La vida loca

    Monday, November 10, 2014 6:51 PM
  • Hello Mark, You can use the ItemAdd event of the Items class to be aware when a new item is added to the folder. The ItemRemove event of the Items class is fired when an item is removed from a folder. You may find the Outlook Items and Folders events explained at http://www.add-in-express.com/creating-addins-blog/2011/09/13/outlook-folders-events/ .
    Monday, November 10, 2014 7:52 PM
  • Hi Mark,

    That sample should give you some good ideas. Take a look at the section titled :

    Responding to Outlook folder events

    I think those examples will get you going.

    Ty 

    Monday, November 10, 2014 10:53 PM
  • My dilemma is that I don't know until runtime, which folders exist.  A folder that was there yesterday may not be there today, so I don't have the luxury of just hardcoding the folder names.  Does that make sense?  
    Tuesday, November 11, 2014 1:25 PM
  • It doesn't make any sense.

    You may get a Folder object which represents the Inbox folder using the GetDefaultFolder of the Namespace or Store class. The Folders property of the Folder class returns an instance of the Folders collection which contains all subfolders. You may iterate over all subfolders and subscribe to the required events. The name of the folder doesn't play any role in that case. For example:

    inboxFolder.Folders.Item(i)

    Tuesday, November 11, 2014 1:31 PM
  • Thanks for your reply!

    Ok.  Cool.  Now I'm intrigued.  Can you provide a code snippet of how to "subscribe to the required events" as I iterate through the folders?  For example the ItemAdd event?

    Tuesday, November 11, 2014 1:59 PM
  • Please refer to links mentioned above.
    Tuesday, November 11, 2014 2:00 PM
  • The links provided above are for 

    1:  Getting the names of the folders.  (Thanks Ty).  This I am already doing.

    2:  A $349 Add-In.  Not the route I was going for.

    I have the names of the folders, I just need to know how to add handlers to those folder names at runtime.  

    Thanks anyway.

    Tuesday, November 11, 2014 2:35 PM
  • The Outlook object model is common for all kind of applications. The code will be the same.

    Take a look at the events of the Items class. For example, a raw sketch:


    folder.Items.ItemAdd+=yourHandler;
    Tuesday, November 11, 2014 2:45 PM
  • Hi HokieMark,

    Have you fixed this issue now? We can use Items.ItemAdd to monitor items add for the specific folder. And if you want to add this event for the folder dynamically, we can use Folders.FolderAdd Event to achieve the goal.

    Every time we add folder in Outlook, we can add ItemAdd event for the specific folder.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, November 18, 2014 10:18 AM
    Moderator