none
Outlook is not displaying modified HTML content in first attempt RRS feed

  • Question

  • HI All,

    I have written VSTO plugin in C#. My requirement is while opening the mail (in Open event of MailItem), I modified the body from some text (which I received from third component in HTML format). I have written following code for this :--

    objMail.BodyFormat = OlBodyFormat.olFormatHTML;
    objMail.HTMLBody = modifiedMessageBody;

    Now, if I open the mail first time, It is not able to display content in body. But after that, from second attempt onwards, It is able to display the content.

    modifiedMessageBody has following value :--

    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
    /* Font Definitions */
    @font-face
    {font-family:"Cambria Math";
    panose-1:2 4 5 3 5 4 6 3 2 4;}
    @font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
    /* Style Definitions */
    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin:0in;
    margin-bottom:.0001pt;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";}
    a:link, span.MsoHyperlink
    {
    color:#0563C1;
    text-decoration:underline;}
    a:visited, span.MsoHyperlinkFollowed
    {
    color:#954F72;
    text-decoration:underline;}
    span.EmailStyle17
    {
    font-family:"Calibri","sans-serif";
    color:windowtext;}
    .MsoChpDefault
    {
    font-family:"Calibri","sans-serif";}
    @page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;}
    div.WordSection1
    {page:WordSection1;}
    --></style><!--[if gte mso 9]><xml>
    <o:shapedefaults v:ext="edit" spidmax="1026" />
    </xml><![endif]--><!--[if gte mso 9]><xml>
    <o:shapelayout v:ext="edit">
    <o:idmap v:ext="edit" data="1" />
    </o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div>

    But in first attempt after assigning this value to HTMLBody of MailItem, when I try to print HTMLBody of MailItem, it shows following value :--

     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
    <HTML>
    <HEAD>
    <META NAME="Generator" CONTENT="MS Exchange Server version rmj.rmm.rup.rpr">
    <TITLE></TITLE>
    </HEAD>
    <BODY>
    <!-- Converted from text/plain format -->

    <P><FONT SIZE=2>格浴浸湬㩳㵶產湲猺档浥獡洭捩潲潳瑦挭浯瘺汭•浸湬㩳㵯產湲猺档浥獡洭捩潲潳瑦挭浯漺晦捩㩥景楦散•浸湬㩳㵷產湲猺档浥獡洭捩潲潳瑦挭浯漺晦捩㩥潷摲•浸湬㩳㵭栢瑴㩰⼯捳敨慭⹳業牣獯景⹴潣⽭景楦散㈯〰⼴㈱漯浭≬砠汭獮∽瑨灴⼺眯睷眮⸳牯⽧剔刯䍅栭浴㑬∰㰾敨摡㰾敭慴渠浡㵥敇敮慲潴⁲潣瑮湥㵴䴢捩潲潳瑦圠牯⁤㔱⠠楦瑬牥摥洠摥畩⥭㸢猼祴敬㰾ⴡഭ⼊‪潆瑮䐠晥湩瑩潩獮⨠യ䀊潦瑮昭捡൥ऊ晻湯⵴慦業祬∺慃扭楲⁡慍桴㬢਍瀉湡獯ⵥ㨱′‴‵″‵‴‶″′㬴ൽ䀊潦瑮昭捡൥ऊ晻湯⵴慦業祬䌺污扩楲഻ऊ慰潮敳ㄭ㈺ㄠ‵‵′′′‴″′㬴ൽ⼊‪瑓汹⁥敄楦楮楴湯⁳⼪਍⹰獍乯牯慭ⱬ氠⹩獍乯牯慭ⱬ搠癩䴮潳潎浲污਍笉慭杲湩〺湩഻ऊ慭杲湩戭瑯潴㩭〮〰瀱㭴਍昉湯⵴楳敺ㄺ⸱瀰㭴਍昉湯⵴慦業祬∺慃楬牢≩∬慳獮猭牥晩㬢ൽ愊氺湩Ⱬ猠慰⹮獍䡯灹牥楬歮਍笉獭ⵯ瑳汹ⵥ牰潩楲祴㤺㬹਍按汯牯⌺㔰㌶ㅃ഻ऊ整瑸搭捥牯瑡潩㩮湵敤汲湩㭥ൽ愊瘺獩瑩摥‬灳湡䴮潳祈数汲湩䙫汯潬敷൤ऊ浻潳猭祴敬瀭楲牯瑩㩹㤹഻ऊ潣潬㩲㤣㐵㝆㬲਍琉硥⵴敤潣慲楴湯町摮牥楬敮紻਍灳湡䔮慭汩瑓汹ㅥഷऊ浻潳猭祴敬琭灹㩥数獲湯污挭浯潰敳഻ऊ潦瑮昭浡汩㩹䌢污扩楲Ⱒ猢湡⵳敳楲≦഻ऊ潣潬㩲楷摮睯整瑸紻਍䴮潳桃䑰晥畡瑬਍笉獭ⵯ瑳汹ⵥ祴数攺灸牯⵴湯祬഻ऊ潦瑮昭浡汩㩹䌢污扩楲Ⱒ猢湡⵳敳楲≦紻਍灀条⁥潗摲敓瑣潩ㅮ਍笉楳敺㠺㔮湩ㄠ⸱椰㭮਍洉牡楧㩮⸱椰⸱椰⸱椰⸱椰㭮ൽ搊癩圮牯卤捥楴湯റऊ灻条㩥潗摲敓瑣潩ㅮ紻਍ⴭ㰾猯祴敬㰾ⴡ嬭晩朠整洠潳㤠㹝砼汭ാ㰊㩯桳灡摥晥畡瑬⁳㩶硥㵴攢楤≴猠楰浤硡∽〱㘲•㸯਍⼼浸㹬ℼ敛摮晩ⵝ㸭ℼⴭ楛⁦瑧⁥獭崹㰾浸㹬਍漼猺慨数慬潹瑵瘠攺瑸∽摥瑩㸢਍漼椺浤灡瘠攺瑸∽摥瑩•慤慴∽∱⼠ാ㰊漯猺慨数慬潹瑵㰾砯汭㰾嬡湥楤嵦ⴭ㰾栯慥㹤戼摯⁹慬杮䔽ⵎ单氠湩㵫⌢㔰㌶ㅃ•汶湩㵫⌢㔹䘴㈷㸢搼癩挠慬獳圽牯卤捥楴湯㸱瀼挠慬獳䴽潳潎浲污栾汥潬漼瀺㰾漯瀺㰾瀯㰾搯癩㰾戯摯㹹⼼瑨汭</FONT></P>

    </BODY>
    </HTML>

    While, when i close that mail and re-open it, it displays the body and I can see that HTMLBody has right value which was assigned to it :--

    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
    /* Font Definitions */
    @font-face
    {font-family:"Cambria Math";
    panose-1:2 4 5 3 5 4 6 3 2 4;}
    @font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
    /* Style Definitions */
    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin:0in;
    margin-bottom:.0001pt;
    font-size:11.0pt;
    font-family:"Calibri","sans-serif";}
    a:link, span.MsoHyperlink
    {
    color:#0563C1;
    text-decoration:underline;}
    a:visited, span.MsoHyperlinkFollowed
    {
    color:#954F72;
    text-decoration:underline;}
    span.EmailStyle17
    {
    font-family:"Calibri","sans-serif";
    color:windowtext;}
    .MsoChpDefault
    {
    font-family:"Calibri","sans-serif";}
    @page WordSection1
    {size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;}
    div.WordSection1
    {page:WordSection1;}
    --></style><!--[if gte mso 9]><xml>
    <o:shapedefaults v:ext="edit" spidmax="1026" />
    </xml><![endif]--><!--[if gte mso 9]><xml>
    <o:shapelayout v:ext="edit">
    <o:idmap v:ext="edit" data="1" />
    </o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div>

    Can someone please suggest what has gone wrong ?

    Thanks

    Dev

    Saturday, August 25, 2018 6:21 AM