1

我在 IIS 8.5 和 Windows 8.1 中使用 CDO 在 Classic ASP 中发送电子邮件时遇到问题,问题发生在拉丁字符上,例如 ñ áéíóúü 等。例如,如果我将 ñ 放在主题和/或正文中,我会得到 Ã ±。

这是我的代码:

Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

With Fields
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing")      = 2 
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")     = "smtp.gmail.com"
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername")   = "email@gmail.com"
 .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")   = "the-pwd-123"
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")     = true
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")   = 1

 .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
 .BodyPart.Charset = "utf-8"
 '.BodyPart.Charset = "unicode-1-1-utf-8"
 .To       = "<email@gmail.com>"
 .From     = "<email2@gmail.com>"
 .Subject  = "Envio de contraseña"
 .TextBody = "This email has a ñ to see how it looks when sending email through CDO"
 .Send
End With

邮箱的配置是UTF8,那么问题出在哪里呢,请问怎么解决呢?

4

1 回答 1

5

首先,尝试将其添加到页面顶部

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>.

此外,由于您的 ñ 是硬编码的,因此请使用 UTF-8 编码保存文件。如果您在记事本(或几乎任何除 VS 之外的编辑器)中打开它并选择另存为,您应该会在出现的对话框中看到一个编码下拉列表。

有关详细信息,请参阅此内容。http://www.hanselman.com/blog/InternationalizationAndClassicASP.aspx

于 2015-02-28T14:38:22.910 回答