none
Detecting changes in email Body RRS feed

  • Question

  • I am creating a VSTO outlook add-in for office 2007 upwards using VSTO4 and .net 4 (client profile).  My development machine is Visual Studio 2012 running Office 2010 sp1.


    Is there any chance I can detect that the user has changed the email body?  

    I have tried using 

    Document wordDocument = Inspector.WordEditor;
    wordDocument.Application.WindowSelectionChanged +=  myEvent;
    however this is not very reliable.

    Any ideas?
    • Edited by Keith Ball Monday, April 8, 2013 2:10 PM
    Monday, April 8, 2013 2:10 PM

Answers

  • Unfortunately the Word and Outlook events that are available don't work well or at all when changing the Body or HTMLBody of mail items.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Keith Ball" <=?utf-8?B?S2VpdGggQmFsbA==?=> wrote in message news:1a34cc48-50e7-4608-9655-0eb4c35c4a1c...

    I am creating a VSTO outlook add-in for office 2007 upwards using VSTO4 and .net 4 (client profile).  My development machine is Visual Studio 2012 running Office 2010 sp1.


    Is there any chance I can detect that the user has changed the email body?  

    I have tried using 

    Document wordDocument = Inspector.WordEditor;
    wordDocument.Application.WindowSelectionChanged +=  myEvent;
    however this is not very reliable.

    Any ideas?

    Ken Slovak MVP - Outlook
    • Marked as answer by Keith Ball Monday, April 8, 2013 2:57 PM
    Monday, April 8, 2013 2:56 PM

All replies

  • Unfortunately the Word and Outlook events that are available don't work well or at all when changing the Body or HTMLBody of mail items.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Keith Ball" <=?utf-8?B?S2VpdGggQmFsbA==?=> wrote in message news:1a34cc48-50e7-4608-9655-0eb4c35c4a1c...

    I am creating a VSTO outlook add-in for office 2007 upwards using VSTO4 and .net 4 (client profile).  My development machine is Visual Studio 2012 running Office 2010 sp1.


    Is there any chance I can detect that the user has changed the email body?  

    I have tried using 

    Document wordDocument = Inspector.WordEditor;
    wordDocument.Application.WindowSelectionChanged +=  myEvent;
    however this is not very reliable.

    Any ideas?

    Ken Slovak MVP - Outlook
    • Marked as answer by Keith Ball Monday, April 8, 2013 2:57 PM
    Monday, April 8, 2013 2:56 PM
  • I suspected as much.  Thanks for the confirmation.

    I really don't want to but maybe I have to use a timer. :(

    Monday, April 8, 2013 2:58 PM
  • If you do use a timer to compare values for Body or HTMLBody make sure it's running on the same thread as the Outlook process. Using the object model from a background thread is not supported and will cause problems, and in Outlook 2013 will actually get Outlook to disable your code.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Keith Ball" <=?utf-8?B?S2VpdGggQmFsbA==?=> wrote in message news:5f255507-6ae9-4567-af51-70df0ce7b798...

    I suspected as much.  Thanks for the confirmation.

    I really don't want to but maybe I have to use a timer. :(


    Ken Slovak MVP - Outlook
    Monday, April 8, 2013 3:14 PM
  • Thanks for the tip.  I have an invisible form that I create on Add-in start up and throw methods at it's BeginInvoke function when I need to use the Outlook thread.
    • Edited by Keith Ball Monday, April 8, 2013 3:28 PM
    Monday, April 8, 2013 3:28 PM