none
Outlook 2013 VSTO Inline Message handling RRS feed

  • Question

  • I have a VSTO project targeting Outlook 2007 that has 2 ribbons created using Visual Designer:

    1. Ribbon1: ribbontype = Microsoft.Outlook.Explorer
    2. Ribbon2: ribbontype = Microsoft.Outlook.Mail.Compose + Microsoft.Outlook.Response.Compose

    I now need to upgrade the project to target Outlook 2013.  This means another Ribbon is required for the *new* Inline Messages.  In order to accomplish this, from what I've read, I need to use Ribbon XML rather than the Ribbon Visual Designer.

    QUESTIONS:

    1. Can one have both Ribbon types (XML and Visual Designer) in the same project. 
    2. In the Application_ItemSend event, I currently have the following snippet of code.  How do I check whether it's Sent from the Inline Message as opposed to an opened inspector window, as I need to check the state of the ToggleButton.
    Private Sub Application_ItemSend(Item As Object, ByRef Cancel As Boolean) Handles Application.ItemSend
      If TypeOf Item Is Outlook.MailItem Then
         Dim olMailItem As Outlook.MailItem = DirectCast(Item, Outlook.MailItem)
         Dim inspector As Outlook.Inspector = olMailItem.GetInspector
         If Globals.Ribbons(inspector).Ribbon2.ToggleButton1.Checked = False Then Exit Sub
      End If
    ...
     

    From my testing so far, it appears that the ItemSend event is fired twice, not sure why.

    Thanks.


    • Edited by J Wagner Wednesday, March 20, 2013 1:47 PM
    Wednesday, March 20, 2013 1:46 PM

Answers

  • Ad 1. no

    Ad 2. check if passes Item parameter to ItemSend is the same as the Explorer.getactiveinlineresponse 

    • Marked as answer by Quist ZhangModerator Thursday, March 28, 2013 3:22 AM
    • Unmarked as answer by J Wagner Wednesday, May 1, 2013 4:02 AM
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:56 AM
    Wednesday, March 20, 2013 3:00 PM
  • Subscribe to Inspectors.NewInspectors(). When that fires, subscribe to the Activate() event for that Inspector if it's one you want to handle.
     
    If more than 1 Inspector is opened at a time it can be difficult to tell which has fired Activate() as ActiveInspector may not change until after Activate() in some cases. You can invalidate the ribbon in Activate(), then in a ribbon callback you can use the control.Context you're passed in the callback to identify the Inspector.
     
    However, using wrapper classes is the easiest, most flexible way to do this and to be able to handle Inspector and item events easily for multiple open Inspectors.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "J Wagner" <=?utf-8?B?SiBXYWduZXI=?=> wrote in message news:d66b176f-acb2-4b03-bc87-90ff8749a8ae...

    Looked around a fair bit on how to intercept the Inspector Activated event.  Can this not be done without the use of wrappers?  I have the following block of code, but have not figured out how to continue from here.

    Private WithEvents objInspectors As Outlook.Inspectors
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    objInspectors = Me.Application.Inspectors
    End Sub

    Thanks.


    Ken Slovak MVP - Outlook
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    Monday, April 29, 2013 1:41 PM

All replies

  • Ad 1. no

    Ad 2. check if passes Item parameter to ItemSend is the same as the Explorer.getactiveinlineresponse 

    • Marked as answer by Quist ZhangModerator Thursday, March 28, 2013 3:22 AM
    • Unmarked as answer by J Wagner Wednesday, May 1, 2013 4:02 AM
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:56 AM
    Wednesday, March 20, 2013 3:00 PM
  • So this means I need to convert the 2 Designer Ribbons to XML. Somehow I would need to differentiate between what Ribbons are loaded as there will be 3 ribbons.

    Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
        Return New Ribbon3()
    ???
    End Function

    1. How do I handle the different Ribbons in the CreateRibbonExtensibilityObject?
    2. Given it will be XML ribbons, I can no longer use the Globals.Ribbons to obtain the current state of the ToggleButton in the ItemSend event.  How would this be handled?
    3. ItemSend event firing twice in Outlook 2013, is this a known issue?
    4. You mention comparing the Item parameter (???) to the explorer.getactiveinlineresponse.  What parameter are you referring to?  Would the following code work just as well?
            Dim app As Outlook.Application = Globals.ThisAddIn.Application
            Dim exp As Outlook.Explorer = app.ActiveExplorer()
    
            If exp.ActiveInlineResponse IsNot Nothing Then
                MsgBox("Inlineresponse")
            End If

    • Edited by J Wagner Wednesday, March 20, 2013 4:57 PM
    Wednesday, March 20, 2013 4:55 PM
  • ad 1 - there is only one ribbon class in XML approach

    ad 2 - you will have to store current state in your own variable, for example in that Ribbon class mentioned above

    ad 3 - i do not think so, or more people would have already asked that question

    ad 4 ItemSend event handler takes Item as first parameter.

    • Marked as answer by Quist ZhangModerator Thursday, March 28, 2013 3:22 AM
    • Unmarked as answer by J Wagner Friday, April 19, 2013 12:38 PM
    • Marked as answer by J Wagner Friday, April 19, 2013 12:38 PM
    • Unmarked as answer by J Wagner Friday, April 19, 2013 12:38 PM
    Thursday, March 21, 2013 8:51 AM
  • Your response ad 2:

    you will have to store current state in your own variable, for example in that Ribbon class mentioned above

    Can you direct me to some code, as I will be dealing with multiple Inspector Windows and thus require the variable set for the current Activate Inspector. 

    Friday, April 19, 2013 12:43 PM
  • If you're using Inspector wrapper classes just declare a Boolean variable in each wrapper class to store the state as on/off (true/false) for a toggle control. You can identify the Inspector from the control.Context property in the ribbon callbacks, then compare each such Inspector with the Inspector in each wrapper class to find the correct Inspector.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "J Wagner" <=?utf-8?B?SiBXYWduZXI=?=> wrote in message news:1d592562-695e-40f5-af3e-4b6de02b061b...

    Your response ad 2:

    you will have to store current state in your own variable, for example in that Ribbon class mentioned above

    Can you direct me to some code, as I will be dealing with multiple Inspector Windows and thus require the variable set for the current Activate Inspector. 


    Ken Slovak MVP - Outlook
    Friday, April 19, 2013 4:05 PM
  • I'm not using wrappers.  Didn't need to when using the Ribbon Designer.  Now it seems I have no option but to revert to using Ribbon XML.  I'm wondering whether it would be better / simpler to invalidate a control whenever an Inspector window is activated, so I can then update a global variable in the callback and then reference that in the itemsend event.     
    Saturday, April 20, 2013 12:20 AM
  • The problem with that is when you need to keep references alive for all open Inspectors (or Explorers) and need to maintain different actions for various open objects. If you can meet your requirements as you suggest then go for it, otherwise consider using wrapper classes.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "J Wagner" <=?utf-8?B?SiBXYWduZXI=?=> wrote in message news:30a027a8-1fba-473d-bea0-fc18e5a3b125...
    I'm not using wrappers.  Didn't need to when using the Ribbon Designer.  Now it seems I have no option but to revert to using Ribbon XML.  I'm wondering whether it would be better / simpler to invalidate a control whenever an Inspector window is activated, so I can then update a global variable in the callback and then reference that in the itemsend event.     

    Ken Slovak MVP - Outlook
    Monday, April 22, 2013 1:54 PM
  • Looked around a fair bit on how to intercept the Inspector Activated event.  Can this not be done without the use of wrappers?  I have the following block of code, but have not figured out how to continue from here.

    Private WithEvents objInspectors As Outlook.Inspectors
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    objInspectors = Me.Application.Inspectors
    End Sub

    Thanks.

    Sunday, April 28, 2013 6:27 PM
  • Subscribe to Inspectors.NewInspectors(). When that fires, subscribe to the Activate() event for that Inspector if it's one you want to handle.
     
    If more than 1 Inspector is opened at a time it can be difficult to tell which has fired Activate() as ActiveInspector may not change until after Activate() in some cases. You can invalidate the ribbon in Activate(), then in a ribbon callback you can use the control.Context you're passed in the callback to identify the Inspector.
     
    However, using wrapper classes is the easiest, most flexible way to do this and to be able to handle Inspector and item events easily for multiple open Inspectors.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "J Wagner" <=?utf-8?B?SiBXYWduZXI=?=> wrote in message news:d66b176f-acb2-4b03-bc87-90ff8749a8ae...

    Looked around a fair bit on how to intercept the Inspector Activated event.  Can this not be done without the use of wrappers?  I have the following block of code, but have not figured out how to continue from here.

    Private WithEvents objInspectors As Outlook.Inspectors
    
    Private Sub ThisAddIn_Startup() Handles Me.Startup
    objInspectors = Me.Application.Inspectors
    End Sub

    Thanks.


    Ken Slovak MVP - Outlook
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    Monday, April 29, 2013 1:41 PM
  • So my question is, is it possible to intercept the Inspector Activated event without using wrappers?
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    • Unmarked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    Tuesday, April 30, 2013 1:01 AM
  • To repeat what I said:
     
    Subscribe to Inspectors.NewInspectors(). When that fires, subscribe to the Activate() event for that Inspector if it's one you want to handle.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "J Wagner" <=?utf-8?B?SiBXYWduZXI=?=> wrote in message news:a299250b-8c53-4114-8dbb-29f2d3ba72cb...
    So my question is, is it possible to intercept the Inspector Activated event without using wrappers?

    Ken Slovak MVP - Outlook
    • Marked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    • Unmarked as answer by J Wagner Wednesday, May 1, 2013 5:55 AM
    Tuesday, April 30, 2013 1:38 PM
  • For some reason or other, the page did not refresh, so I never saw your response.  The thread showed that you had responded, however, opening the thread did not reveal your response.  Not sure why.

    I'll try the wrapper approach.

    Thanks.

    Wednesday, May 1, 2013 5:54 AM
  • Did you see my response now? That you don't need wrappers but they do solve a problem where more than 1 item is opened at the same time.

    If you don't want to use wrappers just take the Inspector handed to you in Inspectors.NewInspector() and subscribe to the Activate() event on that Inspector.


    Ken Slovak MVP - Outlook

    Wednesday, May 1, 2013 1:39 PM