Platform SDK: Exchange 2000 Server

Specifying the Header Fields Character Set

[This is preliminary documentation and subject to change.]

A MIME-formatted message can use one character set for the text or HTML body parts and another character set for the message header fields. In this case, the character set for the header fields must be explicitly set so that the fields are properly encoded using the mechanism defined by RFC 1522.

The following example demonstrates how to explicitly set the character set for the message header fields to iso-2022-jp, whereas the explicit character set for an included html body part is iso-8859-9.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim iMsg As New CDO.Message
With iMsg 
  .From    = """[Japanese Unicode characters]"" <sender@microsoft.com>"
  .To      = """[Japanese Unicode characters]"" <recipient@microsoft.com>"
  .Subject = "[Japanese Unicode characters]"

  ' The character set is iso-8859-1 for the HTML in included Web page
  ' and for the text/plain alternative message text
  .CreateMHTMLBody "http://www.microsoft.com"

  ' The next line sets the character set for the message header fields
  ' to iso-2022-jp.
  .BodyPart.Charset = "iso-2022-jp"
  .Send
End With
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IMessagePtr iMsg(__uuidof(Message));
iMsg->To   = """[Japanese Unicode characters]"" <sender@microsoft.com>";
iMsg->From = """[Japanese Unicode characters]"" <recipient@microsoft.com>";
iMsg->Subject = "[Japanese Unicode characters]";
  /*
  **  The character set is iso-8859-1 for the HTML in the 
  **  included Web page and for the text/plain alternative message text
  */
iMsg->CreateMHTMLBody("http://www.microsoft.com",cdoSuppressNone,"","");

  /*
  ** Now, set the character set for the message header fields
  ** so that they are encoded properly (RFC 1522).
  */
IBodyPartPtr iBp;
iBp = iMsg;
iBp->Charset = "iso-2022-jp";

iMsg->Send();
[VBScript]
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
With iMsg 
  .From    = """[Japanese Unicode characters]"" <sender@microsoft.com>"
  .To      = """[Japanese Unicode characters]"" <recipient@microsoft.com>"
  .Subject = "[Japanese Unicode characters]"

  ' The character set is iso-8859-1 for the HTML in included Web page
  ' and for the text/plain alternative message text
  .CreateMHTMLBody "http://www.microsoft.com"

  ' This next line sets the character set for the message header fields
  ' to iso-2022-jp.
  .BodyPart.Charset = "iso-2022-jp"  
  .Send
End With