none
Can't access a reference to a new mail window in Outlook 2010 RRS feed

  • Question

  • I'm building my first plug-in to Outlook and according to the code here, I'm supposed to add the following code to the event handler.

    new Microsoft.Office.Interop
     
    .Outlook.InspectorsEvents_NewInspectorEventHandler(foo);

    As i type it in, the syntax works (no red underscores) and the code compiles. However, for some reason, the intellisense doesn't present me with that particular option, meaninig I have to type it all by myself. That makes me sad.

    Even worse, as I execute the project, the listener event is fired but the line below doesn't result in an object - mailItem remains null.

    Outlook.MailItem mailItem = inspector as Outlook.MailItem;
      • Why is there no intellisense for .Outlook.InspectorsEvents_NewInspectorEventHandler(foo);?
      • Can I enable it somehow and if so how?
      • How can I access the newly created message frame?

    My bet is that it's got to do with Interop reference and I suspect that it actually doesn't work since the Count field in inspectors equals to zero both before and after the handler adding operation.

    Execution of the line below only returns null, instead of an instance of MailItem, despite the fact that a new mail window opens (with no changes to it, of course). While the input parameter inspector differs from null, the as-'ification seems to nullify it.

    I run VS10/.NET4.

    Thursday, September 6, 2012 12:48 PM

Answers

  • Also, you are casting inspector object to MailItem object, which makes no sense.

    That line should be

    Outlook.MailItemmailItem =inspector.CurrentItem asOutlook.MailItem;

    You must also handle sitiations where you have objects other than messages displayed (contact, appointment, etc) - the cast to MailItem will return null.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, September 6, 2012 2:53 PM

All replies

  • What Intellisense feature/member is missing exactly?  My guess is that you are a VB coder (like myself) who can't stand having to create all of these event handlers in C#!

    Can you verify that the foo method fires for you?  That would be the delegated method that's actually handling the Inspectors.NewInspector event.  If that event fires, there's no way the code provided in the MSDN article for that same event should fail.

    Please show ALL of your code as well.


    Eric Legault MVP (Outlook)
    About me...
    Try Outlook Appins - affordable and easy to use!

    Thursday, September 6, 2012 1:59 PM
    Moderator
  • Also, you are casting inspector object to MailItem object, which makes no sense.

    That line should be

    Outlook.MailItemmailItem =inspector.CurrentItem asOutlook.MailItem;

    You must also handle sitiations where you have objects other than messages displayed (contact, appointment, etc) - the cast to MailItem will return null.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, September 6, 2012 2:53 PM