Get and set the default html text format in outlook RRS feed

  • Question

  • Hello

    I need insert the body into a mailitem while the default signature is used also. It works so far. the only problem is, that the inserted body text format is not the format that is set when i start to write a new mail in outlook. It sets my text to calibri 10. default ist calibri 11, or sometimes arial, but never calibri 10.

    how can i get de configured text format so that i can build it in my htmlbody too?

    Thanks a lot

    mailitem.HTMLBody = bodystring + mailitem.HTMLBody; //(text + signature)

    Friday, August 10, 2012 3:37 PM

All replies

  • Youy cannot concatenate two HTML strings and end up with a valid HTML string. The two need to be merged - e.g. youn need to search for the position of the "<BODY" substring, then find the next occurence of the ">" character (you cannot simply search for "<body>" since body can have attributes),  then insert your HTML string aftyer ">".

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, August 10, 2012 4:15 PM
  • and rememebr about css classes - i think it would be easier to insert your test using word api from mail;s inspector.
    Friday, August 10, 2012 5:45 PM
  • When you get your HTMLBody data, dump it into a DOM type object. It looks like a web page, without the initial

    <?xml version="1.0" encoding="utf-8"?>


    So look for the <body lang="EN-CA" link="blue" vlink="purple"> section and add in there. You may also see the   <div class="WordSection1">, and may have to add it in there, or in a new such section.


    .Net thingy maker type guy.

    Saturday, August 11, 2012 10:50 PM
  • @ Dmitry Streblechenko _MVP_

    thank you for your reply.
    when I edit the mailitem.htmlbody, it automatically puts my insertet Text in the <BODY> Section of the HTML Document. So that's not the problem. When i save the mail as html, my text is on the right position in the html

    • Edited by dynasoftkw Monday, August 13, 2012 8:18 AM
    Monday, August 13, 2012 8:16 AM
  • The position might be right (since Outlook is nice enough to attempt to correct your invalid HTML), but does it have the right style?

    When you look at the exported hTML, what exactly causes the wrong font? Which style specifies calibri 10?

    Dmitry Streblechenko (MVP)
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Monday, August 13, 2012 2:32 PM