Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / August 2006

Tip: Looking for answers? Try searching our database.

Problem with ItemSent event

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
noolyg@yahoo.com - 27 Aug 2006 15:05 GMT
Hello all,

I am writing an outlook plugin for saving emails I send and receive.
For some reason, after a while, the ItemSent event stops and the
delegate doesn't get called when emails are sent.

Any ideas why does that happen? What could be done to prevent it from
happening?

Thanks in advance,

Nool
Josh Einstein - 27 Aug 2006 17:02 GMT
Sounds like the classic "object goes out of scope and get's garbage
collected" issue.

Make sure whenever you bind to events in any .NET application (but
especially COM interop scenarios like Office) that the object remains rooted
for as long as you intend to handle the event. Otherwise the garbage
collector will pick it up and discard it.

The problem is worse in COM interop scenarios because even though the real
object might still be alive (like the Outlook Application object) it's
runtime callable wrapper (RCW) is created on the fly and thrown away when it
goes out of scope. You can hang onto the RCW in a static field or instance
field if need be.

Signature

Josh Einstein / Tablet PC MVP
Einstein Technologies, LLC
-----------------------------------------------------
Tablet Enhancements for Outlook 3.0 Now Available
Unleash the potential of Outlook on your Tablet PC, Origami, or UMPC.
Try it for 15 days - http://www.tabletoutlook.com/Go.ashx?id=ng

> Hello all,
>
[quoted text clipped - 8 lines]
>
> Nool
noolyg@yahoo.com - 29 Aug 2006 06:55 GMT
Thanks for your reply - but I'm am not sure what you mean - what is
getting out of scope?

I'm attaching the delegate to an outlook event - how can I prevent from
it getting out of scope.

Another thing is I played around with it - and the problem only happens
when I use streams - when I do some other (similarly time consuming)
action - it does not happen and the delegate gets called all the time.
Any ideas?

Thanks again.
Nool

> Sounds like the classic "object goes out of scope and get's garbage
> collected" issue.
[quoted text clipped - 30 lines]
> >
> > Nool
Ken Slovak - [MVP - Outlook] - 29 Aug 2006 14:43 GMT
Either declare your item for the event handler at a module level in a class
that never gets released or add the item to a collection or hashtable to
make sure it stays alive and doesn't get garbage collected.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Thanks for your reply - but I'm am not sure what you mean - what is
> getting out of scope?
[quoted text clipped - 9 lines]
> Thanks again.
> Nool
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.