使用 ASP 和 CDOSYS 发送不同语言的邮件

发布于 2024-09-25 16:21:20 字数 1037 浏览 6 评论 0原文

我想发送一封使用阿拉伯语文本作为主题行的电子邮件。

该代码段将消息正文的特殊字符正确转换为阿拉伯文本,但未能将消息主题转换为阿拉伯文本。

我想知道我缺少什么?

      Set objCDOSYS = Server.CreateObject("CDO.Message")
      Set objCDOConf = CreateObject("CDO.Configuration")
      Set objCDOFields = objCDOConf.Fields

      objCDOFields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objCDOFields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
      objCDOFields.Update

      Set objCDOSYS.Configuration = objCDOConf
      objCDOSYS.MimeFormatted=True 
      objCDOSYS.BodyPart.Charset = "Windows-1256"

      objCDOSYS.From = Trim(Request.Form("frmSender"))
      objCDOSYS.To = Trim(Request.Form("frmRecipient"))

      objCDOSYS.Subject =Request.Form("frmSubject")
      objCDOSYS.HTMLBody = Trim(Request.Form("frmMessage")) 

      objCDOSYS.HTMLBodyPart.charset = "Windows-1256"
      objCDOSYS.Fields.update

      objCDOSYS.Send
      Set objCDOFields = Nothing
      Set objCDOConf = Nothing
      Set objCDOSYS = Nothing

I want to send an email using arabic text as subject line.

The code piece converts the special characters into arabic text properly for message body but fails to do so for message subject.

I would like to know what I am missing ?

      Set objCDOSYS = Server.CreateObject("CDO.Message")
      Set objCDOConf = CreateObject("CDO.Configuration")
      Set objCDOFields = objCDOConf.Fields

      objCDOFields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
      objCDOFields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "127.0.0.1"
      objCDOFields.Update

      Set objCDOSYS.Configuration = objCDOConf
      objCDOSYS.MimeFormatted=True 
      objCDOSYS.BodyPart.Charset = "Windows-1256"

      objCDOSYS.From = Trim(Request.Form("frmSender"))
      objCDOSYS.To = Trim(Request.Form("frmRecipient"))

      objCDOSYS.Subject =Request.Form("frmSubject")
      objCDOSYS.HTMLBody = Trim(Request.Form("frmMessage")) 

      objCDOSYS.HTMLBodyPart.charset = "Windows-1256"
      objCDOSYS.Fields.update

      objCDOSYS.Send
      Set objCDOFields = Nothing
      Set objCDOConf = Nothing
      Set objCDOSYS = Nothing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

去了角落 2024-10-02 16:21:20

更改为 UTF-8 字符集值得一试:-

objCDOSYS.HTMLBodyPart.charset = "UTF-8"

我认为这将导致 Jirapong 尝试的编码类型,但 CDOSYS 会为您做到这一点。不幸的是,我知道它不适用于电子邮件地址中的显示名称。

Changing to the UTF-8 charset is worth a stab:-

objCDOSYS.HTMLBodyPart.charset = "UTF-8"

I think that will result in the kind of encoding Jirapong was trying but CDOSYS will do it for you. Unfortunately I know that it doesn't work for display names in the email addresses.

娜些时光,永不杰束 2024-10-02 16:21:20

您可能需要使用“=?UTF-8?B?”位于主题和阿拉伯语 Base64 编码字符串前面。

objCDOSYS.Subject = "=?UTF-8?B?" + Base64Encode(Request.Form("frmSubject"))

Base64Encode 函数可以在 - http://nolovelust.com/post/ 找到classic-asp-base64-encoder-decoder.aspx

注意:我自己也尝试过。所以不是100%确定。

You may need to use '=?UTF-8?B?' in front of subject and the Arabic base64 encoded string.

objCDOSYS.Subject = "=?UTF-8?B?" + Base64Encode(Request.Form("frmSubject"))

The Base64Encode function can find at - http://nolovelust.com/post/classic-asp-base64-encoder-decoder.aspx

Note: I did try this myself yet. so not 100% sure.

靑春怀旧 2024-10-02 16:21:20

对我来说,这 4 项的组合有效:

session.codepage=65001
Response.Charset = "utf-8" 
objMessage.HTMLBodyPart.Charset = "utf-8"
objMessage.BodyPart.Charset = "utf-8"

For me the combination of these 4 items worked:

session.codepage=65001
Response.Charset = "utf-8" 
objMessage.HTMLBodyPart.Charset = "utf-8"
objMessage.BodyPart.Charset = "utf-8"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文