This article demonstrates how to send localized e-mail messages from an Active Server Pages (ASP) page by using Collaboration Data Objects for NTS (CDONTS).
The sample code in this article requires that you have the proper codepages installed on the Internet Information Server (IIS) server, and that you have a way to enter the characters properly in the ASP page's input box. The code uses CDONTS to send a localized SMTP-formatted message. It sets the CHARSET of the ASP page to the localized language. To make sure that the double-byte character set (DBCS) data is generated properly, you will need an Input Method Editor (IME). For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
211147
(http://support.microsoft.com/kb/211147/EN-US/
)
Internet Explorer Script Prompts and MBCS/Unicode
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<!-- <META HTTP-EQUIV="Content-Type" content="text/html;charset=iso-8859-1"> -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=shift_jis">
</HEAD>
<TITLE>CDONTSMail</TITLE>
<% @CODEPAGE=932%>
<%
if not IsEmpty(Request.Form("text1")) then
nCodePage = 932 ' Japanese code page
sFrom = "<Sender's Email address>"
sTo = "<Recipient's Email address>"
sSubj = "This is a test on : " & now()
Set objMail = server.CreateObject("CDONTS.Newmail")
'MSG Text.
objMail.SetLocaleIDs(nCodePage)
' Set the message properties.
objMail.From = sFrom
objMail.To = sTo
objMail.Subject = sSubj
objMail.Body = Request.Form("text1")
' Set the message Format.
objMail.MailFormat = 0 'MIME
objMail.BodyFormat = 1 '0 HTML / 1 Text
' Send the message.
objMail.Send
Set objMail = Nothing
'Output the information.
'Response.Write Request.Form("text1") & "<br>"
sout = Request.Form("text1")
Response.Write "sout: " & sout
end if
%>
<BODY>
<P>Enter the localized message body text below:</P>
<P> </P>
<FORM action="" id=FORM1 method=post name=FORM1>
<INPUT id=text1 name=text1>
<INPUT id=submit1 name=submit1 type=submit value=Submit>
</FORM>
<P> </P>
<P>Note: The the 'From' and 'To' addresses are hard-coded into the ASP
page.</P>
</BODY>
</HTML>
NOTE: If you are using Microsoft Windows 2000 or later, it is recommended that you use CDO for Windows 2000 (CDOSYS) instead of CDONTS. If you are using Microsoft Windows XP or later, CDONTS is not available; CDO for Windows 2000 is recommended for use with Windows XP.