转自 http://blog.csdn.net/dcasc/article/details/8268878
cdo.message使用实例,固定的代码就不做解释了,这里介绍我们需要改动的:
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort=2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig
Dim objMessage
Dim Fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.163.com" <smtp邮件发送服务器>
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = test@163.com <发送者邮件地址>
.Item(cdoSendPassword) = "123456" <发送者邮件密码>
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "shift-jis" <邮件内容编码>
.To = username <接收者邮件地址>
.From = "biz@noonenet.cn" <发送者邮件地址,与上面设置相同>
.Subject = "メールアドレスのご確認" <邮件主题>
.htmlBody = "TEST -- cdo.message" <邮件内容>
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
通过例子看来,很简单吧,希望能帮到大家,调整邮件乱码的问题主要通过.bodypart.charset这个属性即可.
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort=2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig
Dim objMessage
Dim Fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.163.com" <smtp邮件发送服务器>
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = test@163.com <发送者邮件地址>
.Item(cdoSendPassword) = "123456" <发送者邮件密码>
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "shift-jis" <邮件内容编码>
.To = username <接收者邮件地址>
.From = "biz@noonenet.cn" <发送者邮件地址,与上面设置相同>
.Subject = "メールアドレスのご確認" <邮件主题>
.htmlBody = "TEST -- cdo.message" <邮件内容>
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
通过例子看来,很简单吧,希望能帮到大家,调整邮件乱码的问题主要通过.bodypart.charset这个属性即可.
分类:
版权声明:本文为博主原创文章,未经博主允许不得转载。
cdo.message使用实例,固定的代码就不做解释了,这里介绍我们需要改动的:
Const cdoSendUsingMethod="http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort=2
Const cdoSMTPServer="http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort="http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout="http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate="http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic=1
Const cdoSendUserName="http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword="http://schemas.microsoft.com/cdo/configuration/sendpassword"
Dim objConfig
Dim objMessage
Dim Fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "smtp.163.com" <smtp邮件发送服务器>
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTimeout) = 10
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = test@163.com <发送者邮件地址>
.Item(cdoSendPassword) = "123456" <发送者邮件密码>
.Update
End With
Set objMessage = Server.CreateObject("CDO.Message")
Set objMessage.Configuration = objConfig
With objMessage
.BodyPart.Charset = "shift-jis" <邮件内容编码>
.To = username <接收者邮件地址>
.From = "biz@noonenet.cn" <发送者邮件地址,与上面设置相同>
.Subject = "メールアドレスのご確認" <邮件主题>
.htmlBody = "TEST -- cdo.message" <邮件内容>
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
通过例子看来,很简单吧,希望能帮到大家,调整邮件乱码的问题主要通过.bodypart.charset这个属性即可.