我在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,那么问题出在哪里?,我该如何解决?
答案 0 :(得分:5)
首先,尝试将其添加到页面顶部
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
。
此外,由于您的ñ是硬编码的,请使用UTF-8编码保存文件。如果你在记事本中打开它(或者只是VS之外的任何编辑器)并选择另存为你应该在出现的对话框中看到一个编码下拉列表。
有关详细信息,请参阅此处。 http://www.hanselman.com/blog/InternationalizationAndClassicASP.aspx