none
Outlook VSTO Addin - changes to NormalEmail.dotm ignored RRS feed

  • Question

  • Question: How can Outlook be determined to commit the changes to the NormalEmail.dotm file, while also being able to register a callback for WindowSelectionChange event ?

    Problem:

    Outlook discards all changes to the NormalEmail.dotm file whenever a callback is registered for the WindowSelectionChanged event. 

    Details

    For example, any changes to the Quick Part Gallery (Insert->Text->QuickParts) will only be visible during the current session; closing Outlook and starting it again will show the previous list of elements with no modifications visible, including those that were deleted.

    Another symptom of the bug is that when the file is deleted, Outlook should normally re-create it :

    • C:\Users\ [USER] \AppData\Roaming\Microsoft\Templates\ NormalEmail.dotm

    but this won't happen when the Addin is enabled.

    To reproduce the issue

    Register a method (even an empty one) to the WindowSelectionChange event:

    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.Inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(RegisterChangeHandler);
        }
    
        void RegisterChangeHandler(Outlook.Inspector inspector)
        {
            Microsoft.Office.Interop.Word.Application app = Application.ActiveExplorer().ActiveInlineResponseWordEditor?.Application;
    -->     app.WindowSelectionChange += WinSelectionChange; <-- this line causes the bug
        }
    
        private void WinSelectionChange(Selection Sel)
        {
          /* nothing */   
        }
        ...
    }
    

    No exceptions are thrown; the result is the same when putting try/catch blocks in place, or when the callback is unregistered in the Application.Quit event.


    Monday, January 15, 2018 5:01 PM

All replies

  • Hello Andrer_Tudor,

    >>For example, any changes to the Quick Part Gallery (Insert->Text->QuickParts) will only be visible during the current session.......

    In my test, I added a quick part gallery to the NormalMail.dotm and it remains once closing and starting outlook again. I'm using Outlook 2016. What's the version of you office? Could you detail how do you change to the Quick Part Gallery?

    >>while also being able to register a callback for WindowSelectionChange event

    We support one issue for one thread. I failed to know if the issue has any relationship with previous issue. If it has, please detail the relationship. If not, please post a thread for the issue.

    Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 16, 2018 7:58 AM
  • Hi Terry, 

    The problem is that once a callback is registered for WindowSelectionChange event(by an active AddIn), creating a building block item (in QuickParts ...) will be discarded when Outlook is closed.

    - create a very simple AddIn that subscribes to the event, as described in my code

    - activate the addin

    - add an item to the QuickParts Gallery (manually, not in code)

    - close Outlook

    - reopen Outlook

    - => you will notice that the previously added item no longer exists

    Regards,

    Tuesday, January 16, 2018 3:40 PM
  • Hello Andrei_Tudor,

    I got error at

    Microsoft.Office.Interop.Word.Application app = Application.ActiveExplorer().ActiveInlineResponseWordEditor?.Application;

    I won't suggest you keep running the project once you get error. What do you want to do? RegisterChangeHandler will trigger once opening a new inspector. However, you get application of an InlineResponse Word editor.

    Could please detail your requirements so we could try to make the code work?

    Best Regards,

    Terry



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 17, 2018 10:26 AM
  • Hi Terry


    The code I posted is a very simplified version, just to show the behavior.

    The error does indeed happen when trying to open a message for reading; but you can also replicate the bug without encountering an exception. All you need to do is start Outlook and begin writing a "New Message". Here you can add/remove building blocks in the Quick Parts Gallery, then close the "Mew Message" window, then close Outlook.

    The above steps will raise no exception, but you will see that the changes made to the Quick Parts Gallery will be lost.

    Saturday, January 20, 2018 10:47 AM
  • Hello,

    I could run your code with an inline response visible in the read pane. This issue does exist and I would suggest you go to File->Feedback to submit a feedback for this this issue.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, January 23, 2018 10:39 AM
  • Thanks, Terry!

    Can you confirm then that this is a bug in MS Outlook and that you can't provide a solution for it?

    Also, is there any point in filing something through the feedback? Will anyone ever look at it and provide a solution?

    Regards,
    Andrei


    Thursday, January 25, 2018 4:30 PM