A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

OpenSharedItem and .MSG files



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 17th 08, 05:20 PM posted to microsoft.public.outlook.program_addins
SeekerOfTruths
external usenet poster
 
Posts: 4
Default OpenSharedItem and .MSG files

Hi, I'm having a little difficulty with OpenSharedItem in the Outlook 2007
add-in that I'm writing.

The purpose of the add-in is to detect when the user opens (double-clicks)
certain items and to retrieve an alternative item which has been stored
elsewhere (i.e. not in Exchange) and present this item in an inspector window
instead of the original item.

I can hook into the Open event no problem, and when this event fires I
perform a check on the item being opened to see if it needs special
treatment. If it does I acquire the alternative item to be opened (as a file
on disk), use OpenSharedItem to give me back a object referencing the item on
disk, create a new inspector window using this new item and then cancel the
open event on the original item.

This all seems to work fine, except for the fact that when I close the
inspector window containing the alternative item, a handle to the file on
disk remains open which prevents the file on disk from being deleted. This
would suggest that there is still an object somewhere that is referencing the
item on disk, but I''m not sure where the reference is or how to go about
tracking it down (I've set all the instances that I'm aware of to null in my
code).

If anyone could give me suggestions on what might be wrong and/or how to
track down the problem, I'd be very grateful.


Thanks,

SeekerOfTruths
  #2  
Old December 17th 08, 06:34 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default OpenSharedItem and .MSG files

..NET code or what? If this is .NET code are you releasing the object
reference you got from OpenSharedItem() possibly even by calling
Marshal.ReleaseComObject() on it and then calling
GC.WaitForPendingFinalizers()?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"SeekerOfTruths" wrote in message
news
Hi, I'm having a little difficulty with OpenSharedItem in the Outlook 2007
add-in that I'm writing.

The purpose of the add-in is to detect when the user opens (double-clicks)
certain items and to retrieve an alternative item which has been stored
elsewhere (i.e. not in Exchange) and present this item in an inspector
window
instead of the original item.

I can hook into the Open event no problem, and when this event fires I
perform a check on the item being opened to see if it needs special
treatment. If it does I acquire the alternative item to be opened (as a
file
on disk), use OpenSharedItem to give me back a object referencing the item
on
disk, create a new inspector window using this new item and then cancel
the
open event on the original item.

This all seems to work fine, except for the fact that when I close the
inspector window containing the alternative item, a handle to the file on
disk remains open which prevents the file on disk from being deleted. This
would suggest that there is still an object somewhere that is referencing
the
item on disk, but I''m not sure where the reference is or how to go about
tracking it down (I've set all the instances that I'm aware of to null in
my
code).

If anyone could give me suggestions on what might be wrong and/or how to
track down the problem, I'd be very grateful.


Thanks,

SeekerOfTruths


  #3  
Old December 17th 08, 11:54 PM posted to microsoft.public.outlook.program_addins
SeekerOfTruths
external usenet poster
 
Posts: 4
Default OpenSharedItem and .MSG files

Sorry, I should have said what it was written in to begin with - yes, it's
..Net (C#) code. Unfortunately .Net and C# are kind of new tech to me (I'm
more of a C++ Extended MAPI store provider kind of person) so I'm just sort
of writing the code and picking things up as I go along (very bad practice I
know, but needs must when the devil drives).

I did try throwing in a ReleaseComObject call to see if it had any effect
but didn't notice any change in behaviour, but then I hadn't included any
garbage collection calls.

"Ken Slovak - [MVP - Outlook]" wrote:

..NET code or what? If this is .NET code are you releasing the object
reference you got from OpenSharedItem() possibly even by calling ReleaseComObject on the item, but
Marshal.ReleaseComObject() on it and then calling
GC.WaitForPendingFinalizers()?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"SeekerOfTruths" wrote in message
news
Hi, I'm having a little difficulty with OpenSharedItem in the Outlook 2007
add-in that I'm writing.

The purpose of the add-in is to detect when the user opens (double-clicks)
certain items and to retrieve an alternative item which has been stored
elsewhere (i.e. not in Exchange) and present this item in an inspector
window
instead of the original item.

I can hook into the Open event no problem, and when this event fires I
perform a check on the item being opened to see if it needs special
treatment. If it does I acquire the alternative item to be opened (as a
file
on disk), use OpenSharedItem to give me back a object referencing the item
on
disk, create a new inspector window using this new item and then cancel
the
open event on the original item.

This all seems to work fine, except for the fact that when I close the
inspector window containing the alternative item, a handle to the file on
disk remains open which prevents the file on disk from being deleted. This
would suggest that there is still an object somewhere that is referencing
the
item on disk, but I''m not sure where the reference is or how to go about
tracking it down (I've set all the instances that I'm aware of to null in
my
code).

If anyone could give me suggestions on what might be wrong and/or how to
track down the problem, I'd be very grateful.


Thanks,

SeekerOfTruths



  #4  
Old December 18th 08, 03:12 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default OpenSharedItem and .MSG files

Let's say I have an object oMail. When finished with it I'd use code like
this, assuming that I have no need for any other references to that object
in any context at all:

if (oMail != null)
{
Marshal.ReleaseComObject(oMail);
oMail = null;
}

GC.Collect();
GC.WaitForPendingFinalizers();

That call to ReleaseComObject releases the RCW for that oMail object.

The down side to that is if you have live references to the underlying mail
item represented by oMail anywhere else in your program.

Those will become invalid when the RCW is released since the Interop only
creates 1 RCW no matter how many object references to the object you
instantiate in different scopes.

So when passing a reference to oMail by value to a procedure if the
procedure releases the RCW the passed reference will be invalid in the
calling procedure.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"SeekerOfTruths" wrote in message
...
Sorry, I should have said what it was written in to begin with - yes, it's
.Net (C#) code. Unfortunately .Net and C# are kind of new tech to me (I'm
more of a C++ Extended MAPI store provider kind of person) so I'm just
sort
of writing the code and picking things up as I go along (very bad practice
I
know, but needs must when the devil drives).

I did try throwing in a ReleaseComObject call to see if it had any effect
but didn't notice any change in behaviour, but then I hadn't included any
garbage collection calls.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My .pst folder is too full.... Deleted Files Empty & Old Files Del AggieDusty Outlook - Installation 1 May 2nd 08 11:18 PM
OpenSharedItem - Exception Andre Maas Add-ins for Outlook 2 October 10th 07 03:29 PM
Windows Explorer 7: Lost game files & fighting to open files & bro Totally Frustrated 7 Outlook Express 4 February 2nd 07 03:07 PM
Converting iCal (mac) .ics files to Outlook .vcs files [email protected] Outlook - Calandaring 1 March 22nd 06 03:30 AM
Converting iCal (mac) .ics files to Outlook .vcs files Adam Outlook - General Queries 0 March 10th 06 07:40 PM


All times are GMT +1. The time now is 12:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.