Office Addin upgrade c# code from Office Outlook 2007 to 2010

Answered Office Addin upgrade c# code from Office Outlook 2007 to 2010

  • segunda-feira, 16 de abril de 2012 17:34
     
     

    Hi,
    We have a C# addin working in officeOutlook 2007 and we can catch the user events  via eventhandler
    outlookExplorer2007.SelectionChange+=

    newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);

    We can´t get the similar code to catch the OutLook events in Office 2010.
    Application2010.ActiveExplorer().SelectionChange +=

    newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);

    Best regards and thanls in advance José




     

Todas as Respostas

  • terça-feira, 17 de abril de 2012 06:26
     
     

    Hello,

    Check out the links below for events in outlook 2010. IT may help you.

    http://msdn.microsoft.com/en-us/library/bb610520.aspx

    http://msdn.microsoft.com/en-us/library/ee692172.aspx

  • terça-feira, 17 de abril de 2012 07:28
     
     

    Hi José,

    Could you please describe in more detail your problem?
    Also: If you run the code from the following link, does the SelectionChange event get triggered?

    How to: Determine the Current Outlook Item
    http://msdn.microsoft.com/en-us/library/ms268994(v=vs.100).aspx

    Marcel

  • terça-feira, 17 de abril de 2012 13:55
     
     

    hi

    thanks for you help

    the following code works fine in office 2007 but not in office 2010.

    the problem is ExplorerEvents_10_SelectionChangeEventHandler is only for office 2007 has far has I figer out

    privatevoidThisAddIn_Startup(objectsender, System.EventArgse)

            {
                currentExplorer = this.Application.ActiveExplorer();
                currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
            }

  • terça-feira, 17 de abril de 2012 14:16
     
     
    The following code works fine in office 2007 but not in office 2010. The problem is: ExplorerEvents_10_SelectionChangeEventHandler is only for office 2007 as far as I figuered out.

    I'm afraid that is not correct. The ExplorerEvents_10 interface is fully supported by Outlook 2010. To convince yourself of the fact, simply fire up VS 2010 an create a new Outlook 2010 Add-in project. Then paste in the code from the above link. I just tested it, and it worked as expected. There are some known issues with items getting locked by Outlook 2010, but this is not the problem mentioned here.

    Once again, please test the code, and *please* describe in more detail the meaning of "the following code works fine in Office 2007, but not in Office 2010". Does the code compile? Do you get an error message? Place a breakpoint in the CurrentExplorer_Event handler. Does it get hit?

    Marcel



  • terça-feira, 17 de abril de 2012 14:16
     
     

    What version of 2010 do you have installed (x32, or x64)?

    What Interop Version are you referencing in your Visual Studio project?


    jdweng

  • terça-feira, 17 de abril de 2012 15:02
     
     

    What version of 2010 do you have installed (x32, or x64)?

    What Interop Version are you referencing in your Visual Studio project?


    jdweng

    I've installed Microsoft Office X64 and the project is X64 too.

    The interop is V14.0.0

  • terça-feira, 17 de abril de 2012 15:07
     
     

    Since you have Outlook 2007 you need to Outlook Interop 12.0, not 14.0


    jdweng

  • terça-feira, 17 de abril de 2012 15:29
     
     

    i need the addin running in Outlook 2010 not in 2007... in 2007 its already working...

    We have a C# addin working inOffice Outlook 2007 and we can catch the user events  via eventhandler
    outlookExplorer2007.SelectionChange+=newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);

    We can´t get the similar code to catch the OutLook events in Office 2010.
    Application2010.ActiveExplorer().SelectionChange += newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);

  • terça-feira, 17 de abril de 2012 15:51
     
     Resposta Proposta

    Sorry, I didn't notice that you said 2007 was working.

    I would check to make sure you have the latest hot fixes in outlook.  The following webpage indicates there was problems in 2010 with service routines in Outlook 2010

    http://support.microsoft.com/kb/2586274


    jdweng

  • quarta-feira, 18 de abril de 2012 08:15
     
     

    @Joel, Mike:

    There is no problem with the ExplorerEvents_10 interface in Outlook 2010. Just try out the sample code which I linked to above, and you'll see that everything works just smoothly.

    Marcel

  • quinta-feira, 19 de abril de 2012 13:36
    Moderador
     
     Respondido
    It is never wise to assume that you have an ActiveExplorer() object, especially at Outlook startup. If anything you should check the Explorers collection for Count > 0 and if so use Explorers[1] instead.
     
    The SelectionChange() event is as valid for Outlook 2010 as for 2007. I usually use a different way of instantiated that handler that works equally well in Outlook 2003, 2007, 2010 and later versions. This line assumes an Explorer object, _explorer, declared at class level to keep it alive:
     
        ((Outlook.ExplorerEvents_Event)_explorer).SelectionChange += new Outlook.ExplorerEvents_SelectionChangeEventHandler(Explorer_SelectionChange);
     
    The way you're adding the handler, using compound dot operators and ActiveExplorer() will get garbage collected and eventually fail to fire. That will happen in Outlook 2007 as well, so you need to change your code there also.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Vasco_G" <=?utf-8?B?VmFzY29fRw==?=> wrote in message news:4d014f9b-4263-458b-9286-f27c09836764...

    i need the addin running in Outlook 2010 not in 2007... in 2007 its already working...

    We have a C# addin working inOffice Outlook 2007 and we can catch the user events  via eventhandler
    outlookExplorer2007.SelectionChange+=newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);

    We can´t get the similar code to catch the OutLook events in Office 2010.
    Application2010.ActiveExplorer().SelectionChange += newExplorerEvents_10_SelectionChangeEventHandler(myOlExp_SelectionChange);


    Ken Slovak MVP - Outlook