Message Object : Charset Property |
Visual Basic |
---|
Public Property Charset As String |
When communicating with international mail clients, you may need to be aware of Unicode character encoding/decoding issues. At the highest level, character encoding/decoding can be viewed as taking a visual string representation displayable in a UI, translating that visual string representation into a multi-byte values for transmission between systems, then retranslating the multi-byte values back into the original visual string (Unicode) representation. For this operation to occur successfully, the correct preferred character set must be specified so that the correct codepage is used. A codepage is a mapping between a Unicode visual character and a multi-byte sequence. This mapping is unique for different codepages.
When Message.Charset is specified, the value only affects text that is added by using Message.Text. This will no impact any of the parts. To specify the character set on a part, Part.Charset must be set.
In order to properly decode the encoded data back to its original form, you must know the character set that was used to encode the data. When dealing with message data or message part data, this information can be found in the "charset" label of the "content-type" header like so:
Content-Type: text/plain; charset="big5"
The label above signifies that the data in this part was encoded using Chinese Big5 Unicode character set. Character sets map to an ANSI CodePage, in this case CodePage 950 for the big5 preferred character set, which define the multi-byte representation for a given Unicode character in the character set.
When creating a message, this property will default to the current system preferred character set. Set this property to override this behavior and specify a different character set. For example, if your operating system character set is "iso-8859-1" and you wish to use a Japanese character set, you would set this property to "iso-2022-jp".
When reading messages this property will contain the character set string used to encode the message or message part (if one was used).
This property applies to message/message parts only. To get/set the character set used to encode header fields, see HeaderFields.Charset.