Sending emails with non ASCII characters from Classic ASP

classic asp
This post is old, and probably obsolete

To have an ASP page send an email with non-ASCII European text (Cyrillic, Greek, Czech, etc) you'll need to use UTF-8.

Saving Source Files As UTF-8

First all, make sure you save the actual ASP files itself as UTF-8, and make sure it is the correct type of UTF-8 (i.e., not "UTF-8 no BOM"). Then you need to specify the character encoding for the page itself. If you saved the page as UTF-8, then you can use the codepage attribute in the language tag as follows: <%@ Language=JScript CodePage=65001 %>

Alternatively, if you are not able to save pages in UTF-8 and session management is on, you can use a the CodePage attribute of the Session object, which allows the response to be different from the encoding of the file itself. <% Session.CodePage=650001 %>

Although not essential, you may also want to set the character set explicity, both in the Response object and as a meta tag: Response.Charset="UTF-8"

and as a meta tag: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Saving A Mail Message As UTF-8 WIth CDO.Message

The above will ensure your web page is served properly. But what about the email content? If you use CDO.Message to send emails, then it is pretty simple - just use set the charset property:

var objMail = Server.CreateObject( "CDO.Message" );
objMail.BodyPart.charset = "unicode-1-1-utf-8";
objMail.From     = '';
objMail.To       = '';
objMail.Cc       = '';
objMail.Subject  = 'Text email';
objMail.TextBody = 'Hello. just a text email';
objMail.HTMLBody = ' ... ';
objMail.AddAttachment( 'asd' );