How to set message encoding in EWS? RRS feed

  • Question

  • I want set encoding for my HTML messages. I insert in "HTML" body this tag:

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    But when I save my message value of "charset" changes to "koi8-r". 

    I found property PidTagInternetCodepage (PR_INTERNET_CPID - 0x3FDE) which should help me. But when I save message with "HTML" body, value of "charset" same changes to "koi8-r" and text becomes unreadable. Although in Outlook (and MIME) I can see that the encoding has changed to the desired.

    Maybe there is another way to change the character set (without set MimeContent) or am I doing something wrong?

    Thursday, June 1, 2017 4:27 PM

All replies

  • What's the encoding of the SOAP message your sending ? eg first line

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


    Friday, June 2, 2017 6:12 AM
  • I use EWS Managed API. It creates the following query:

    Content-Type: text/xml; charset=utf-8
    Accept: text/xml
    Accept-Encoding: gzip,deflate
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="" xmlns:m="" xmlns:t="" xmlns:soap="">
        <t:RequestServerVersion Version="Exchange2010_SP1" />
        <m:CreateItem MessageDisposition="SaveOnly">
            <t:DistinguishedFolderId Id="drafts" />
              <t:Body BodyType="HTML">&lt;html&gt;&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

    As a result, message with encoding "koi8-r". MIME: 

    To: "" <>
    Subject: =?koi8-r?B?8NLPwszFzcE=?=
    Thread-Topic: =?koi8-r?B?8NLPwszFzcE=?=
    Thread-Index: AQHS32dJ/Bj1YgtQYUCmNGUxGDw7+g==
    Content-Language: en-US
    Content-Type: multipart/alternative;
    MIME-Version: 1.0
    Content-Type: text/plain; charset="koi8-r"
    Content-Transfer-Encoding: quoted-printable
    Content-Type: text/html; charset="koi8-r"
    Content-Transfer-Encoding: quoted-printable
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dkoi8-r">
    • Edited by vangog163 Wednesday, June 7, 2017 8:43 AM Formatting
    Wednesday, June 7, 2017 8:39 AM
  • Mime generation should be done on the fly by the store have you tried posting the MIME content directly to see if that changes it


    Thursday, June 8, 2017 4:54 AM
  • Thank you, Glen.
    Outlolok for Mac (use EWS API) posting the MIME content directly and in this case the desired encoding does not change
    But I would like MIME was generated on the store side. For this reason, I experimented with the property PidTagInternetCodepage (PR_INTERNET_CPID - 0x3FDE).
    Maybe there is a way without posting the MIME content directly?
    Thursday, June 8, 2017 8:40 AM