none
Inspector event wrapper to resolve MSG file issues RRS feed

  • Question

  • Hello,

     

    I'm working on a VSTO 2010 / VB.net addin for Outlook 2010

    I could find few information about msg files not being released after they were opened/closed - error message "The file may not exist, you may not have permission to open...." then appears when trying to open the file again.

    The solution seems to be releasing / cleaning objects when the inspector get closed.
    I can successfuly manage the new inspector events, but could not implement the close event - the information and  samples  I could find are mostly on C or too complicated for me to understand them.

    So I'm just looking for a basic (mailitem only) inspector event wrapper sample, that I could use when inspectors get closed.

     

    Thank you for your help

     

    Friday, November 4, 2011 2:58 PM

Answers

  • I finally could find a 2010 VB sample on MSDN (http://archive.msdn.microsoft.com/odcOL14InspectorWrap/Release/ProjectReleases.aspx?ReleaseId=4926), mixed with previous sample you provided it's now OK.

     

    Thanks to both of you.

    Tuesday, November 8, 2011 10:17 AM

All replies

  • You can take a look at the Inspector wrapper samples from my book at http://www.slovaktech.com/outlook_2007_templates.htm. The samples are for VS 2005 but you can import or adapt them.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Support BOSSARD" <=?utf-8?B?U3VwcG9ydCBCT1NTQVJE?=> wrote in message news:0064c3af-004c-48c9-8d40-0e5b4fc67021...

    Hello,

     

    I'm working on a VSTO 2010 / VB.net addin for Outlook 2010

    I could find few information about msg files not being released after they were opened/closed - error message "The file may not exist, you may not have permission to open...." then appears when trying to open the file again.

    The solution seems to be releasing / cleaning objects when the inspector get closed.
    I can successfuly manage the new inspector events, but could not implement the close event - the information and  samples  I could find are mostly on C or too complicated for me to understand them.

    So I'm just looking for a basic (mailitem only) inspector event wrapper sample, that I could use when inspectors get closed.

     

    Thank you for your help

     


    Ken Slovak MVP - Outlook
    Friday, November 4, 2011 3:06 PM
  • Ken,

     

    Thank you for your reply, I saw this sample before but got a little lost while trying to implement it.

    I'll try again, and maybe I can ask for some help then.....

     

    Thanks

    Friday, November 4, 2011 10:44 PM
  • Hi,

    Thanks for your post.

    As Close is the name of both a method and an event on Inspector object, you need to cast the inspector object to InspectorEvents_10_Event interface to use this event. See the code:

            Outlook.Inspector inspector =null;
            Outlook.Inspectors inspectors = null;   
    
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                inspectors = Application.Inspectors;
                inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(inspectors_NewInspector);
            }
    
            void inspectors_NewInspector(Outlook.Inspector Inspector)
            {
                if (inspector == null)
                {
                    inspector = Inspector;
                    ((Outlook.InspectorEvents_10_Event)inspector).Activate += new Outlook.InspectorEvents_10_ActivateEventHandler(Inspector_Activate);
                    ((Outlook.InspectorEvents_10_Event)inspector).Close += new Outlook.InspectorEvents_10_CloseEventHandler(Inspector_Close);
                }
              
            }
    
            void Inspector_Close()
            {
                ((Outlook.InspectorEvents_10_Event)inspector).Activate -= new Outlook.InspectorEvents_10_ActivateEventHandler(Inspector_Activate);
                ((Outlook.InspectorEvents_10_Event)inspector).Close -= new Outlook.InspectorEvents_10_CloseEventHandler(Inspector_Close);
                inspector = null;
            }
            void Inspector_Activate()
            {
    
            }
    

    I hope this helps.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, November 7, 2011 7:08 AM
    Moderator
  • Calvin,

    Thanks for your reply, I was looking for VB.net sample, not sure about how to "translate" this one

    Stéphane

    Monday, November 7, 2011 8:21 AM
  • I finally could find a 2010 VB sample on MSDN (http://archive.msdn.microsoft.com/odcOL14InspectorWrap/Release/ProjectReleases.aspx?ReleaseId=4926), mixed with previous sample you provided it's now OK.

     

    Thanks to both of you.

    Tuesday, November 8, 2011 10:17 AM