Search Persits Software Knowledge Base

 

Article PS040220129

AspEmail - Problems with foreign and Unicode characters

Problem Description

When sending a message with AspEmail using foreign non-ASCII character sets, characters do not come through properly and appear as garbage.

Solution

There can be several causes of this type of problem.

1. Make sure you have upgraded to AspEmail 5.0 or later. Older versions did not have full support for foreign character sets. 5.0 is a free upgrade from any previous AspEmail purchase.

2. Make sure you are setting Mail.Charset to a valid value as described in the AspEmail Manual.

Mail.Charset = "UTF-8"

3. Set Mail.ContentTransferEncoding.

Mail.ContentTransferEncoding = "quoted-printable"

4. Set a page Codepage header, if your script is using hard-coded character constants. The value for Unicode UTF-8 is 65001; see Microsoft documentation for other locale-specific codepages.

<% @codepage=65001 %>

5. Set Session.CodePage with the same value.

Session.CodePage=65001

6. To accept non-Ascii values typed into HTML forms, include an HTML META charset tag in the <HEAD> area of both the HTML form page and the ASP script page (these may be the same page):

<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8">
</HEAD>

7. Use EncodeHeader as specified in the AspEmail manual for headers such as Subject and From.

Mail.Subject = Mail.EncodeHeader("Unicode text here", "UTF-8")

8. Use the Request.Form collection explicitly to access all user posted data, not the generic Request collection.

Example:
Mail.Body = Request.Form("BodyText") 'like this
Mail.Body = Request("BodyText") 'not like this!

9. If you are building Mail.Body using string variables that are populated from a source such as a database, ensure that they contain valid data. Ensure that your data is not encoded already, as it will come out garbled if AspEmail re-encodes already-encoded data.

If you follow all these steps, AspEmail will format and send messages as per the MIME standards. Any further difficulty in displaying such messages will be due to the email client, not AspEmail itself.

We recommend using Unicode UTF-8 rather than specific localized character sets (Hebrew, Arabic, Russian, etc.) Unicode is now a mature, widely-supported standard that many programs and browsers deal with better than localized encodings.

Created: 2/20/2004 5:19:18 PM
Last Modified: 5/11/2004 1:01:14 PM

Copyright © Persits Software, Inc. 1998 - 2018
For technical support, write to support@persits.com.