CDO.Message使用详细介绍




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"    
  .Item(cdoSMTPServerPort) = 25                  
  .Item(cdoSMTPConnectionTimeout) = 10     
  .Item(cdoSMTPAuthenticate) = cdoBasic 
  .Item(cdoSendUserName) = [email protected]   <发送者邮件地址>
  .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 = "[email protected]"                           <发送者邮件地址,与上面设置相同>
  .Subject = "メールアドレスのご確認"                    <邮件主题>
  .htmlBody = "TEST -- cdo.message"               <邮件内容>
  .Send 
  End With 
  
  Set Fields = Nothing 
  Set objMessage = Nothing 
  Set objConfig = Nothing
通过例子看来,很简单吧,希望能帮到大家,调整邮件乱码的问题主要通过.bodypart.charset这个属性即可.

你可能感兴趣的:(ASP)