Group:  Microsoft Outlook ยป microsoft.public.outlook.program_addins
Thread: ItemAdd in Deleted Items event doesnt fire after a while

Geek News

ItemAdd in Deleted Items event doesnt fire after a while
lin.en.shu[ at ]gmail.com 1/5/2007 7:33:33 AM
I'm having this problem where i can't find a solution on my own and
neither can i find and posted solution around the web or forums. The
scenario is this : In order to trace the deleted items, i had added an
ItemAdd event on the deleted items folder to handle the entryid of the
deleted items. Well, it works in the beginning, but somehow i observed
this, after a while, specifically after i deleted a few of them and
after that added a few of them, it no longer handle the ItemAdd of the
deleted items folder. This is strange, and i need urgent help. Thanks.

Re: ItemAdd in Deleted Items event doesnt fire after a while
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 1/5/2007 5:27:51 PM
This is an indication that you are not storing the Items collection in a
variable that stays referenced. As soon as the GC kicks in, the intermediate
variable is released and you no longer received events.


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


<lin.en.shu[ at ]gmail.com> wrote in message
news:1167982413.037706.94790[ at ]i15g2000cwa.googlegroups.com...
[Quoted Text]
> I'm having this problem where i can't find a solution on my own and
> neither can i find and posted solution around the web or forums. The
> scenario is this : In order to trace the deleted items, i had added an
> ItemAdd event on the deleted items folder to handle the entryid of the
> deleted items. Well, it works in the beginning, but somehow i observed
> this, after a while, specifically after i deleted a few of them and
> after that added a few of them, it no longer handle the ItemAdd of the
> deleted items folder. This is strange, and i need urgent help. Thanks.
>


Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/5/2007 9:28:47 PM
hmm..great. But frankly, I must first apologize because I'm a starter,
and I don't really understand by what you mean of storing the items
collection in a variable that stays referenced. On top of that, how do
I implement that? Please tolerate my incompetencies. Thank you very
much. I deeply appreciate your technical advice.

Re: ItemAdd in Deleted Items event doesnt fire after a while
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 1/5/2007 11:22:39 PM
You probably have something like

MAPIFolder.Items.ItemAdd += new ...

but it must be

m_Items = MAPIFolder.Items; //must be a class rather than a local variable
m_Items.ItemAdd += new ...

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"SHUperb" <lin.en.shu[ at ]gmail.com> wrote in message
news:1168032527.308331.182730[ at ]v33g2000cwv.googlegroups.com...
[Quoted Text]
> hmm..great. But frankly, I must first apologize because I'm a starter,
> and I don't really understand by what you mean of storing the items
> collection in a variable that stays referenced. On top of that, how do
> I implement that? Please tolerate my incompetencies. Thank you very
> much. I deeply appreciate your technical advice.
>


Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/6/2007 8:47:00 AM
I think I did the right one on this. I declare it as a class like how u
put it

myFolders = MAPIFolder....
myItems = myFolders.Items;
myItems.ItemAdd += new ...

but i still face the problem. Any other idea how to solve this?

Re: ItemAdd in Deleted Items event doesnt fire after a while
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 1/6/2007 4:17:36 PM
Show more of your code.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"SHUperb" <lin.en.shu[ at ]gmail.com> wrote in message
news:1168073220.344736.313590[ at ]v33g2000cwv.googlegroups.com...
[Quoted Text]
>I think I did the right one on this. I declare it as a class like how u
> put it
>
> myFolders = MAPIFolder....
> myItems = myFolders.Items;
> myItems.ItemAdd += new ...
>
> but i still face the problem. Any other idea how to solve this?
>


Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/7/2007 2:44:45 AM
public void OnStartupComplete(ref System.Array custom)
{

myNamespace = applicationObject.GetNamespace("MAPI");
myFolder =
myNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
myItems = myFolder.Items;

myDNamespace = applicationObject.GetNamespace("MAPI");
myDFolder =
myDNamespace.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems);
myDItems = myDFolder.Items;

try
{
myItems.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(myItems_ItemAdd);
myItems.ItemChange += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemChangeEventHandler(myItems_ItemChange);
myItems.ItemRemove += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(myItems_ItemRemove);
myDItems.ItemAdd += new
Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(myDItems_ItemAdd);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Re: ItemAdd in Deleted Items event doesnt fire after a while
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 1/7/2007 9:11:36 PM
Are you sure you never set myDItems to null?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"SHUperb" <lin.en.shu[ at ]gmail.com> wrote in message
news:1168137885.267883.67500[ at ]51g2000cwl.googlegroups.com...
[Quoted Text]
> public void OnStartupComplete(ref System.Array custom)
> {
>
> myNamespace = applicationObject.GetNamespace("MAPI");
> myFolder =
> myNamespace.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
> myItems = myFolder.Items;
>
> myDNamespace = applicationObject.GetNamespace("MAPI");
> myDFolder =
> myDNamespace.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems);
> myDItems = myDFolder.Items;
>
> try
> {
> myItems.ItemAdd += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(myItems_ItemAdd);
> myItems.ItemChange += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemChangeEventHandler(myItems_ItemChange);
> myItems.ItemRemove += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemRemoveEventHandler(myItems_ItemRemove);
> myDItems.ItemAdd += new
> Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(myDItems_ItemAdd);
> }
> catch (System.Exception ex)
> {
> MessageBox.Show(ex.Message);
> }
> }
>


Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/8/2007 2:05:52 AM
Nope. I did not set any null at anywhere of the whole code.

Re: ItemAdd in Deleted Items event doesnt fire after a while
"Dmitry Streblechenko" <dmitry[ at ]dimastr.com> 1/8/2007 3:57:39 AM
You might want to create a small sample add-in that does nothing but monitor
ItemAdd event for the Deleted Item folder and post its source in this
newsgroup (if the problem still manifests itself).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"SHUperb" <lin.en.shu[ at ]gmail.com> wrote in message
news:1168221951.946338.169310[ at ]q40g2000cwq.googlegroups.com...
[Quoted Text]
> Nope. I did not set any null at anywhere of the whole code.
>


Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/8/2007 8:25:22 AM
The problem is solved

private void myDItems_ItemAdd(object Item)
{
//myDItems = myDFolder.Items; //previously my friend told me to add
this line to refresh the folder. but after commenting it out it fixed
the problem.
AppointmentItem item = (AppointmentItem)Item;
//blah blah
}


Dmitry Streblechenko wrote:
[Quoted Text]
> You might want to create a small sample add-in that does nothing but monitor
> ItemAdd event for the Deleted Item folder and post its source in this
> newsgroup (if the problem still manifests itself).
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
> "SHUperb" <lin.en.shu[ at ]gmail.com> wrote in message
> news:1168221951.946338.169310[ at ]q40g2000cwq.googlegroups.com...
> > Nope. I did not set any null at anywhere of the whole code.
> >

Re: ItemAdd in Deleted Items event doesnt fire after a while
"SHUperb" <lin.en.shu[ at ]gmail.com> 1/8/2007 8:27:07 AM
Thanks for your guidance. I appreciate it very much.

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net