带有 UTF-8 的 ASPEmail 产生乱码 [英] ASPEmail with UTF-8 produces scrambled characters

查看:42
本文介绍了带有 UTF-8 的 ASPEmail 产生乱码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我,为什么这段代码不起作用?邮件已发送,但字符被打乱了.

Can anybody tell me, why this code is not working? The mail gets sent, but the characters are scrambeled up.

日本语"变成了日本語"

"日本語" becomes "日本語"

"テスト 日本语 äöü" 变成了 "テスト 日本語 äöü"

"テスト 日本語 äöü" becomes "テスト 日本語 äöü"

<%

    Session.CodePage = 65001    ' UTF-8 code

%>

<!DOCTYPE html>

<html>
<head>
    <title>MAIL TESTER</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>

<%

    strSubject = "日本語"
    strBody = "テスト 日本語 äöü"

    Set objEmail = Server.CreateObject("Persits.MailSender")

    objEmail.Host = "..."
    objEmail.From = "..."
    objEmail.FromName = "..."
    objEmail.AddAddress "..."

    objEmail.Username = "..."
    objEmail.Password = "..."


    objEmail.CharSet = "UTF-8"
    objEmail.ContentTransferEncoding = "Quoted-Printable"
    objEmail.IsHTML = True

    objEmail.Subject = objEmail.EncodeHeader(strSubject, "UTF-8")
    objEmail.Body = strBody

    objEmail.Send


    Set objEmail = Nothing

%>

MAIL SENT.

</body>
</html>

推荐答案

我必须在所有页面上添加以下代码:

I had to add the following code on all the pages:

Session.CodePage = 65001
Response.Charset = "UTF-8"

Response.CodePage = 65001
Response.Charset = "UTF-8"

然后在记事本++中,我必须确保使用UTF-8编码"保存文件.我的页面被保存为在没有 BOM 的情况下以 UTF-8 编码".我不知道他们为什么这样得救,但事实就是这样.

and then in notepad++, I had to make sure that the files are saved with the "Encode in UTF-8". My pages were saved as "Encode in UTF-8 without BOM". I don't know why they were saved like that, but that's how it was.

这篇关于带有 UTF-8 的 ASPEmail 产生乱码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆