关于urn:schemas:mailheader:subject中文显示乱码,如何解决?

ddalone 2002-03-05 06:25:42
我用

Response.Write Rs.Fields("urn:schemas:mailheader:subject").Value
来显示邮件的标题。

英文的显示没有问题,但是中文的显示了“=?utf-8?B?5L2g5aW95ZWK?=”之类的东西
怎么解决??
...全文
167 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
ddalone 2002-03-07
  • 打赏
  • 举报
回复

发邮件的时候我使用的是OWA,我想应该没问题的吧,我去试试,有可能发邮件的时候包含了一些乱码……
ddalone 2002-03-07
  • 打赏
  • 举报
回复

慢着慢着,新问题又来了……

我用asp写一段发邮件的程序,结果收件人那边是好了,但标题和内容却又变成了乱码

居然是这种

è??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè?
?ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò
?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?òè??ò?ò

我的发邮件的程序很简单,就是下面这样的

<%
Set objMail = Server.CreateObject("CDONTS.NEWMAIL")

objMail.From = "abc@csdn.net"
objMail.To = Request.Form("mail_to")
objMail.Cc = Request.Form("mail_cc")
objMail.Bcc = Request.Form("mail_bcc")
objMail.Subject = Request.Form("mail_subject")
objMail.Body = Request.Form("mail_body")
objMail.Send
Set objMail = Nothing

Response.Write "收件人:"&Request.Form("mail_to")&"<br>"
Response.Write "主题:"&Request.Form("mail_subject")&"<br>"
Response.Write "抄送:"&Request.Form("mail_cc")&"<br>"
Response.Write "暗送:"&Request.Form("mail_bcc")&"<br>"
Response.Write "内容:"&Request.Form("mail_body")&"<br>"
Response.Write "<br>电子邮件发送成功!!"
%>

然后用urn:schemas:httpmail:subject搜索出来显示

请帮忙…………
ddalone 2002-03-07
  • 打赏
  • 举报
回复
我自己写了一个asp的程序发邮件,结果没出现问题!
但用OWA发送邮件的时候却出现了问题,还是在收件人的地方。
不知道什么原因。

散分了…………
ddalone 2002-03-07
  • 打赏
  • 举报
回复
怎么回事,好象给分有问题啊
ddalone 2002-03-07
  • 打赏
  • 举报
回复
怎么回事,好象给分有问题啊
ddalone 2002-03-07
  • 打赏
  • 举报
回复

问题搞定,得谢两个人

acptdta(微软全球技术中心 桌面产品技术支持) 和 storm97(风暴不再)

问题出在我是用的 CreateObject("CDONTS.NEWMAIL") 发邮件,
而不是 CreateObject("CDO.message")

好了,问题解决,散分,哈哈…………

acptdta 2002-03-07
  • 打赏
  • 举报
回复
感谢您使用微软产品。



发信时,您需对发出的邮件指定使用的字符集。 这样接收端才可以准确显示出来。 在您的ASP代码中,似乎没有指定GB2312字符集。以下是一段用CDO200(CDONTS的超集)做的例子, 如果您用Windows 2000的话,可以试一试:



1. Introduction


Sometime we may need to send readable mail with Simplified Chinese characters programmatically with CDO 2.0 in our application, web application etc. It is one common scenario in real world in China. It will be very easy in Windows 2000 platform because we can use CDO 2.0 for Windows 2000 object library.



2. More information


For Internet mails, the proper Charset Property should be defined properly before sending the mail according with the language used in the mail. The following is the correct Charset list for some common language for Internet mails.



Language CharSet



Simplified Chinese gb2312

Traditional Chinese big5

English iso-8859-1



If the Charset used doesn’t match with the language in the Internet mails, the mails may be not readable.



3. Sample codes and how to use it


You can perform the following steps to test the sample codes.



1. Create one Windows Application project in VB 6.0. Click menu Project -> Reference… -> check “Microsoft CDO 2.0 for Windows 2000” and “Microsoft ActiveX Data Object library 2.6” in “Available Reference” list.



2. In the VB form, drag two textbox controls, one commandbutton control on it. Name them as txtSubject, txtMailbody and cmdSendMail.



3. Double click the commandbutton control, then copy the following codes between line “Private Sub cmdSendMail_Click()” and line “End Sub”.





Dim iConf As CDO.Configuration

Set iConf = CreateObject("CDO.Configuration")



Dim Flds As ADODB.Fields



Set Flds = iConf.Fields

‘Send the message using the network (SMTP protocol over the network).

Flds("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort

‘Replace the value with your SMTP email server

Flds("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTPmailservername"

‘General port is 25 for SMTP mail.

Flds("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

‘cdoAnonymous indicates Do not authenticate, please note the setting for this property, you should know whether

‘your SMTP server allow anonymous access, if not you need use other authentication method and supply

‘additional information such as user and password, please check reference section below.



Flds("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous

‘Replace the value with the sender email address.

Flds("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = """administrator"" <administrator@ruiworkshop.com>"

Flds.Update



Dim iMsg As CDO.Message

Dim iBp As CDO.IBodyPart

Dim objMsgFlds As Fields



Set iMsg = CreateObject("CDO.Message")

Set iMsg.Configuration = iConf

Set objMsgFlds = iMsg.Fields



‘cdoHigh indicates High importance.

objMsgFlds("urn:schemas:httpmail:importance") = cdoHigh

objMsgFlds.Update



‘Replace the value with receiver’s email address.

iMsg.To = “administrator@ruiworkshop.com”

‘Replace the value with sender’s email address.

iMsg.From = "administrator@ruiworkshop.com"

iMsg.Subject = txtSubject.Text

iMsg.TextBody = txtMailbody.Text



Set iBp = iMsg.TextBodyPart



‘The Charcet for Simplified Chinese language.

iBp.Charset = "gb2312"

‘The Charcet for English language.

‘iBp.Charset = "iso-8859-1"

iMsg.Send





4. Press F5 to execute the application.



5. In Windows form, type in some Simplified Chinese characters into txtSubject and txtMailbody controls, then click cmdSendMail button.



6. In Client, you will see readable mails with Simplified Chinese characters.



7. If you use switch from line



iBP.Charcet=”gb2312”



to



iBP.Charcet=”iso-8859-1”



You will see the mail with Simplified Chinese characters are not readable because we use wrong Charcet (iso-8859-1 is for English language) for the mail with Simplified Chinese characters.



4. Reference


The CdoProtocolsAuthentication enumeration is used to specify the mechanism used when authenticating to a Simple Mail Transfer Protocol (SMTP) service over the network.

Name
Value
Description

cdoAnonymous
0
Do not authenticate.

cdoBasic
1
Use basic (clear-text) authentication. The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.

cdoNTLM
2
Use NTLM authentication (Secure Password Authentication in Microsoft® Outlook® Express). The current process security context is used to authenticate with the service.






希望这些讯息对您有帮助。


- 微软全球技术中心 DTA技术支持



本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
ddalone 2002-03-06
  • 打赏
  • 举报
回复

书上说: urn:schemas:httpmail:namespace是用于创建消息的核心属性,采用MIME标准编码的全部字符串属性是作为Unicode字符解码返回的。

而 urn:schemas:mailheader:namespace用于创建消息属性,这个属性定义包含Internet标准消息标题值的字段。每个属性以US-ASCII字符存储,且与消息流中的ASCII字符串一样。非US-ASCII字符按照MIME标准编码,当设置或更新属性值时不执行会话。

我把里面的凡是涉及到中文的地方,都把mailheader的地方换成httpmail了,大多数书可以的,但是还有urn:schemas:httpmail:to (返回初始消息收件人)这个不行。显示的还是乱码。如果用Unicode(utf-8)查看的话则部分正确部分错误。

还有发件人用的是urn:schemas:httpmail:sendername
发件人mail用的是urn:schemas:httpmail:fromemail
显示是正确的。
但是收件人的地方却不行。显示收件人应该用哪个属性呢?
好象都不行的。这里的fromname=sendername?
frommail=sendermail?
收件人的只有一个to,其他的好象没有了……

请指教,谢谢……
acptdta 2002-03-06
  • 打赏
  • 举报
回复
感谢您使用微软产品。



试试这个属性而不是:urn:schemas:mailheader:subject。



urn:schemas:httpmail:subject



这个属性包含 unicode 的字符,而上一个属性包含按RFC1522 encoded字符.


希望这些讯息对您有帮助。


- 微软全球技术中心 DTA技术支持



本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
acptdta 2002-03-06
  • 打赏
  • 举报
回复
感谢您使用微软产品。



在urn:schemas:httpmail: namespace下的字段主要被用来向Web浏览器提交讯息, 尤其当邮件头讯息是非英文字符的情况下或您不确定被使用的编码集。 在urn:schemas:mailheader: namespace 下的字段总是返回英文字符或按RFC 1522定义的编码机制编码过的字符。显示收件人应该用应该用urn:schemas:httpmail:to. 我用下列代码得到正确的结果。



Response.Write Rs.Fields("urn:schemas:httpmail:to").Value & "</br>"



如果您收到的信已含有不正确的编码,该属性将返回不正确的讯息。


希望这些讯息对您有帮助。


- 微软全球技术中心 DTA技术支持



本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。

535

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧