Detect FolderChange, FolderDelete and FolderAdd

  • Thread starter Thread starter semut
  • Start date Start date
S

semut

Hello,

What is the recommended and effective way to detect any FolderChange,
FolderDelete and FolderAdd event in OUtlook. That include when user right
click on a folder and through context menu, add new folder, or delete or
rename a folder.

Is it event sink all availble MAPIFolder's folders collections when
first started Outlook and add more event sink when there are new MAPIFolder
added, unadvise related event sink when MAPIFolder remove.

Then, later when exit Outlook, unadvise all one by one. (all the
MAPIFolder).


Please advise.


thanks.
 
I am trying to catch any FolderChange, FolderDelete and FolderAdd occur in
Outlook.

The current event model of OOM is that I need to sink each folder collection
I am interested. The solution that I have is to advice and unadvice the
MAPIFolder OnBeforeFolderChange but that only working on the Items Event and
not to FolderEvent cause user can add/remove/rename folder through context
menu. I trying to come out with a proper workaround for this. Any better
approach??

thanks
 
You need to sink off of the explorer events. For example folder change is
event 0xf003 in the explorer events.
 
Thank you for your reply,
The 0xf003 is for event ExplorerEvent::BeforeFolderSwitch which I already
did for the attempt to detect the folder switch and sink on and off. The
problem is that it can't detect the context menu (right click) function
like rename, delete and add when user right click on a folder, the sink
off/on for Folder collection is not accurate when user choose to use context
menu to do rename, add and remove folder.
The context menu click is non detectable by Outlook OOM event sink as far as
I know. Any workaround?
 
the 0xf003 is event for ExplorerEvent::BeforeFolderSwitch which I already
did.

The problem is that it can't detect context menu click on function like
Folder Add, Folder rename and
folder delete.

Any workaround?
 
I just added an event sink (folder add) for my inbox folder and used the
context menu to add a folder to my inbox folder. It caught the event no
problem. Are you sure you sinked to the folder that you right clicked on?
 
Yup, the event sink could detect. My problem is to set up the event sink to
that particular folder. I need something dynamic. I am using
BeforeFolderSwitch at the moment.


My initial problem
 
What language? I have an ATL class that allows dynamic folder event sinks.
 
Probably I should make it clearer.

I could dynamically folder event sink, the classes are available in ATL I
know . And the Outlook could detect the folder event (although,
FolderDeletion could not detect the last folder deletion in a Folder
collection, but that could be overcome with some algorithm) . The problem is
that I could not accurately determine "when" should dynamically event sink
for the needed folder collection.

As you know, the befoforefolderswitch (which is the time to dynamically
event sink) only occur if user open the folder, that is by left clicking a
folder. If user choose to right click on a folder and through context menu
do some folder stuff. There is no way to determine if the user is clicking
on that particular folder. Therefore, the dynamic event sink approach could
not be a right approach to achieve what I want, to detect any folder
collection happen in Outlook.

The CommandBarUpdate could detect the user right click but after some test,
to my dissapointment, the event happen in an inconsistent manner.

The ultimate approach that I could think of is to event sink all the folder
collections in the Outlook and when there are Folder added/ remove. Then,
the corresponding new folder collection will get event sink / unadvice.

The only problem of me to this is the overhead it might cause, imagine
there are many folders in Outlook.

Anyway, thanks for your reply.
 
Back
Top