none
InternetCodepage vs. PR_MESSAGE_CODEPAGE- Especially with HTML Body RRS feed

  • Question

  • when looking at outlook i can find two properties telling me what codepage a mailitem has

    • Internet Codepage Property
    • PR_MESSAGE_CODEPAGE -> 0x3FFD0003 What are the intentions of the two different codepage values?

    When looking at an E-Mail with an HTML Body there can also be a encoding in the HTML .

    So what is the correct way to interpret the HTML Body ?

    In a current mail which is UTF-8 encoded, the internetcodepage returns 65001 (correkt) the PR_MESSAGE_CODEPAGE returns (1252) and html encoding tat says UTF-8

    Can I rely on the internetcodepage? An other developer told me that this sometimes didn't return the correct value, but he hasn't an example for this.

    So whats the best approach to find the encoding of the HTML Body and / or Subject of a mail?

    Wednesday, June 20, 2012 12:09 PM

Answers

  • If you are only dealing with the HTML body, look at the HTML header to check if it specifies the encoding.

    For other properties (if the store is not Unicode enabled), I usually use PR_INTERNET_CPID. If it is not available, then I use PR_MESSAGE_CODEPAGE.

    I don't know if there a reason to prefer one over another...


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Wednesday, June 20, 2012 2:41 PM
  • If the HTML body itself has the encoding in the header, I would trust that. If not, use PR_INTERNET_CPID.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, June 21, 2012 5:11 AM

All replies

  • If you are only dealing with the HTML body, look at the HTML header to check if it specifies the encoding.

    For other properties (if the store is not Unicode enabled), I usually use PR_INTERNET_CPID. If it is not available, then I use PR_MESSAGE_CODEPAGE.

    I don't know if there a reason to prefer one over another...


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Wednesday, June 20, 2012 2:41 PM
  • So in your experience is it reliable to trust in outlook, that it's respecting the encoding set in the HTML tag ? and if it changes the encoding it would change the html tag too?
    Thursday, June 21, 2012 5:05 AM
  • If the HTML body itself has the encoding in the header, I would trust that. If not, use PR_INTERNET_CPID.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, June 21, 2012 5:11 AM