none
Identifying HTML Table in email and Outlook removing id attributes RRS feed

  • Question

  • Hi there,

    I'm developing an Outlook 2010 AddIn using VSTO 2012 and I'm having trouble identifying a html table upon sending the email because it looks like Outlook strips out all the id and class attributes in html tags. 

    Basically, my vba code needs to identify a specific html table that's embedded in an email message when the email is being sent. This specific html table is inserted into the email body (using VBA code) when a user clicks a custom button. I wrote some code (triggered by user clicking a button) that parses the email body for the table using the id attribute and it works well. Now when I use the same code in the OnItemSend() subroutine that intercepts sending of the email, it doesn't work because Outlook has stripped out the id attributes. 

    How can I prevent Outlook from removing the table's id attribute OR what's a good way of identifying the specific html table when parsing every email that's being sent by a user.

    Thanks,

    Hiren.

    Tuesday, October 22, 2013 10:47 PM

Answers

  • You cannot prevent Outlook from changing the HTML, even if you completely write the HTML into HTMLBody. Outlook, and the WordMail email editor, will do what they want with your HTML.

    What you need to do, as your HTML will be specific to your application, is to be empirical. Send the emails to yourself or some other email address you have access to and examine the resulting raw HTML to see what's there. From that you should be able to see what survives and what you need to look for.


    Ken Slovak MVP - Outlook

    • Marked as answer by HirenM Thursday, October 24, 2013 4:05 PM
    Thursday, October 24, 2013 2:48 PM
    Moderator

All replies

  • How do you insert a html table into the email body?

    If conveniently, please share your code here so that we can quickly figure out the problem.


    Thursday, October 24, 2013 10:12 AM
  • You cannot prevent Outlook from changing the HTML, even if you completely write the HTML into HTMLBody. Outlook, and the WordMail email editor, will do what they want with your HTML.

    What you need to do, as your HTML will be specific to your application, is to be empirical. Send the emails to yourself or some other email address you have access to and examine the resulting raw HTML to see what's there. From that you should be able to see what survives and what you need to look for.


    Ken Slovak MVP - Outlook

    • Marked as answer by HirenM Thursday, October 24, 2013 4:05 PM
    Thursday, October 24, 2013 2:48 PM
    Moderator
  • Ken,

    Thanks for the confirmation. I'll look for an empirical method then.

    Thursday, October 24, 2013 4:05 PM