I want to change the body at reply (also at replyAll and forward), so that the composer already get the modified message. So the SendEvent is not a possible solution. But in the reply event the changes at HTMLBody affects the original message immediately and forever. Changes are also instant visible in another Outlook instance. The composer (inline and window) don't show the change on the first editing.
I checked the subject of the "response object" and it already has the prefix "RE:" and is really the response itself. I don't understand, how to change only the response part.
I could also use the inspector of the response, but I don't know how to make the changes with the HTML editor. Using the word editor sounds like an overkill, so I didn't try.
My very simplified code:
using System;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Windows.Forms;
namespace OutlookAddInTEST
{
public partial class ThisAddIn
{
private Outlook.Application _application = null;
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
_application = Globals.ThisAddIn.Application;
_application.ItemLoad += new Outlook.ApplicationEvents_11_ItemLoadEventHandler(_application_ItemLoad);
}
private void ThisAddIn_Reply(object response, ref bool cancel)
{
Outlook.MailItem mitem = (Outlook.MailItem)response;
mitem.HTMLBody = mitem.HTMLBody.Replace("</body>", "# TEST # </body>");
}
Outlook.ItemEvents_10_Event _item;
private void _application_ItemLoad(object Item)
{
_item = (Outlook.ItemEvents_10_Event)Item;
_item.Reply += new Outlook.ItemEvents_10_ReplyEventHandler(ThisAddIn_Reply);
}
}
}