我有一个HTML表单添加到IIS,我使用asp.net发送电子邮件;在拉丁字符我没有问题;然而,当我在收件箱问号中收到阿拉伯语字母时。以下是asp
中的代码<%
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=utf-8"
Response.CodePage = 65001
Response.CharSet = "utf-8"
'EmailSubject = request.querystring("subject")
EmailBody = request.querystring("name") & " " & request.querystring("email") & vbcrlf & request.querystring("message")
Const EmailFrom = "sender@gmail.com"
'Const EmailFromName = request.querystring("fullname")
Const EmailTo = "recepient@gmail.com"
Const SMTPServer = "smtp.gmail.com"
Const SMTPLogon = "user@gmail.com"
Const SMTPPassword = "password"
Const SMTPSSL = True
Const SMTPPort = 465
Const cdoSendUsingPickup = 1 'Send message using local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using SMTP over TCP/IP networking.
Const cdoAnonymous = 0 ' No authentication
Const cdoBasic = 1 ' BASIC clear text authentication
Const cdoNTLM = 2 ' NTLM, Microsoft proprietary authentication
' First, create the message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = EmailSubject
objMessage.From = """" & EmailFromName & """ <" & EmailFrom & ">"
objMessage.To = EmailTo
objMessage.HtmlBody = EmailBody
' Second, configure the server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = SMTPLogon
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = SMTPPassword
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = SMTPSSL
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.BodyPart.Charset = "utf-8"
objMessage.Configuration.Fields.Update
'Now send the message!
On Error Resume Next
objMessage.Send
%>
我尝试了许多没有运气的字符集(例如Windows-1256,ISO-8859-6)
提前致谢
答案 0 :(得分:0)
最后,我找到了一个解决方案,我删除了下面的行
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=utf-8"
Response.CodePage = 65001
Response.CharSet = "utf-8"
并在Set objMessage = CreateObject("CDO.Message")
代码下添加:
objMessage.BodyPart.Charset = "utf-8"