Folder OnItemAdd Event

Add-in Express™ Support Service
That's what is more important than anything else

Folder OnItemAdd Event
When the Folder OnItemAdd event fires you get wrong folder 
mnielsen@caelix.com




Posts: 12
Joined: 2004-08-13
I've got a serious problem that I can't fugure out. I have an event for each of my folders that fires the OnItemAdd passing my the item that was added.

The problem I have is that I need to know what folder the new item is in. This code is acurate in all cases except when I drag and drop a message from one folder to another and then in a majority of the cases the parent folder of the item is not accurate and is actually the folder that the item was moved from not the folder that it is in currently. I am working on a sample for you if you want it.
Posted 26 Aug, 2004 16:12:55 Top
Eugene Starostin


Guest


Hi,

Could you please send us your sample add-in. Tomorrow we will examine it and let you know about a solution.

Also please note that we do not answer questions related to COM development and to host application object models:
http://www.add-in-express.com/support/


We will not have a time to develop if we start this. :-)
Posted 26 Aug, 2004 16:22:05 Top
mnielsen2002




Posts: 12
Joined: 2004-08-13
Here is a sample. To test just try to drag a email from the inbox into a subfolder of the inbox. Do this a couple of times and you will see that most of the time when you drag from the inbox into the subfolder the even fires but the parent folder of the item is still the old folder.

http://www.caelix.net/sample.zip
Posted 26 Aug, 2004 16:53:48 Top
Eugene Starostin


Guest


Matt,

What Outlook do you use - 2000, 2002 or 2003?

I have just tried (about 50 times) to reproduce that you described but it works fine. I tested on Outlook 2000.
Posted 26 Aug, 2004 17:39:29 Top
Eugene Starostin


Guest


I have forgotten. I have Outlook 2000 SP-3.
Posted 26 Aug, 2004 17:40:26 Top
Eugene Starostin


Guest


BTW. I suggest to use the AddInBeginShutdown event to release all references to COM objects. In your case they are folders.
Posted 26 Aug, 2004 17:43:40 Top
mnielsen2002




Posts: 12
Joined: 2004-08-13
We have tried this on Outlook 2002 SP3 and Outlook 2003 SP1. This problem happens a majority of the time on those two system. Meaning that if I tried 5 times it would happen 4 out of 5 times. I have also tried this on other machines with Outlook 2002 SP3 with the same problem.
Posted 26 Aug, 2004 18:16:30 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hello,

The problem exists on Outlook 2002 and Outlook 2003. Our tests also showed that in Outlook XP this is a common problem.

I think the problem can be solved by using the following code:

procedure TAddInModule.OnAddToFolder(ASender: TObject; const AItem: IDispatch);
begin
  if ASender is TItems then
    ShowMessage(OleVariant((ASender as TItems).Parent).Name);
end;

http://www.add-in-express.com/projects/ol_move_items.zip

Also you should be aware about the following KB articles:
OL2000 - http://support.microsoft.com/?kbid=249156
OL2002 - http://support.microsoft.com/?kbid=290653
OL2003 - At the moment doesn't exist but (I suppose) will be published. ;-)

Sincerely,
ADX Support Team
Posted 27 Aug, 2004 10:02:40 Top
mnielsen2002




Posts: 12
Joined: 2004-08-13
Thank you that works fine now.
Posted 30 Aug, 2004 13:16:38 Top