我在 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,那么问题出在哪里呢,请问怎么解决呢?