decorative image for this page

Sending emails with non ASCII characters from ASP

22nd September 2006 10:43 | Categories: HowTo, ASP

To have an ASP page send an email with non-ASCII European text (Cyrillic, Greek, Czech, etc) you’ll need to use 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”). To do that in Dreamweaver, bring up the Page Properties menu (cmd/ctrl J or Modify > Page Properties…), select the Title/Encoding tab, and make sure you have UTF-8 selected and the BOM ticked. In BBEdit, you can achieve the same by clicking on the File Properties button (the fifth from the right in the file editor window). 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" />

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 = 'sender@example.com';
objMail.To = 'receiver@example.com';
objMail.Cc = 'cc@example.com';
objMail.Subject= 'Text email';
objMail.TextBody = 'Hello. just a text email';
objMail.HTMLBody = ' ... ';
objMail.AddAttachment( 'asd' );

this is what fritz looks like

Email | Resume

This is a post within the site. You can navigate through posts via the links labelled 'next', or click on 'search/sitemap' at the top right handside of the page to navigate more quickly.

RSS

ampersand

Fritz is an Italian chap who's been living and working in London for almost 20 years.

He's currently technical director for an integrated digital agency.

In the past he's been a chef, a musician, and author of comics.

home

How to use a meta tag to redirect a page

2007-07-23 19:46 | Tags Javascript / DHTML, HowTo

Using the "meta-refresh" technique for redirecting to a new URL is bad, but sometimes there's no other way to go. ...

Sending emails with non ASCII characters from ASP

2006-09-22 10:43 | Tags HowTo, ASP

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

Reading multi language text in Microsoft Office

2006-07-27 15:26 | Tags Microsoft / Windows, HowTo

Reading documents with Cyrillic text is a breeze on a Mac, but with MS Office it can be a right ...