任何人都可以告诉我,为什么这段代码不起作用? 邮件被发送,但字符被拼凑起来。
“日本语”变成“æ-¥æœ¬èªž”
“テスト日本语äöü”变成“テã,ããã€æ-¥æœ¬èªžÃ¤Ã¶Ã¼”
<%
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>
答案 0 :(得分:0)
我必须在所有页面上添加以下代码:
Session.CodePage = 65001
Response.Charset = "UTF-8"
或
Response.CodePage = 65001
Response.Charset = "UTF-8"
然后在notepad ++中,我必须确保使用“UTF-8中的编码”保存文件。我的页面保存为“没有BOM的UTF-8编码”。我不知道他们为什么会这样得救,但就是这样。