Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to change Mail HTML body from VSTO Outook 2007 add-in
    primarykey
    data
    text
    <p>The plot: </p> <p>I am creating an outlook 2007 add-in using VSTO and C# in Visual Studio 2010. The purpose of the add-in is to cause tracking of mails sent to customers. The add-in should insert a tracking code into every outbound mail that later enables it to be recognized and auto archived once the customer replies. My goal is to insert a tracking code as an attribute in the opening tag of the mail's HTML:</p> <pre><code>&lt;html tracking="ddfwer4w5c45cgx345gtg4g" ...&gt; </code></pre> <p>This will be done in the event handler of the Application.ItemSend event:</p> <pre><code>private void ThisAddIn_Startup(object sender, System.EventArgs e) { this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend); } void Application_ItemSend(object Item, ref bool Cancel) { if (Item is Outlook.MailItem) { Outlook.MailItem mail = (Outlook.MailItem)Item; mail.HTMLBody = "&lt;html tracking=\"4w5te45yv5e6ye57j57jr6\" ..."; } } </code></pre> <p>The problem:</p> <p>It seem to never change the HTMLBody property. And it does not throw any exceptions. It just does nothing. I rewrote this logic directly in VBA in Outlook, and tried to change the HTMLBody, but it still did not change. How I know it did not change the HTMLBody is by stepping through and hovering over the property to see the current value. </p> <p>I am however able to make changes to the MailItem.Body property. But since I need to hide the tracking code in some way, the Body property does not help me at all. I also added the MailItem.Save() method after changing the HTMLBody property, but no change.</p> <p>I thought that perhaps the ItemSend event is to late and I can't change the HTMLBody at that time anymore, but I can't find any event like BeforeSend or alike. </p> <p>Any ideas would be much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload