asp中用CDO发送简单电子邮件

 用CDO发送简单电子邮件的例子。很简单。带入如下:

 

  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     '    As   CDO.Configuration     
   Dim    objMessage    '    As   CDO.Message     
   Dim    Fields        '    As   ADODB.Fields     
    
  
Set    objConfig    =    Server.CreateObject( " CDO.Configuration " )     
  
Set    Fields    =    objConfig.Fields     
    
  
With    Fields     
    .Item(cdoSendUsingMethod)   
=    cdoSendUsingPort     
    .Item(cdoSMTPServer)   
=     " mail.cccar.com.cn "            ' smtp服务器地址     
    .Item(cdoSMTPServerPort)    =     25      
    .Item(cdoSMTPConnectionTimeout)   
=     10      
    .Item(cdoSMTPAuthenticate)   
=    cdoBasic     
    .Item(cdoSendUserName)   
=    "用户名 "     ' 发送者的用户名     
    .Item(cdoSendPassword)    =     "口令 "       ' 发送者的密码     
    .Update     
  
End     With      
    
  
Set    objMessage    =    Server.CreateObject( " CDO.Message " )     
  
Set    objMessage.Configuration    =    objConfig     
    
  
With    objMessage     
    .To         
=     " ljc@cccar.com.cn "       ' 接收者的邮件地址     
    .From        =     " ljc@cccar.com.cn "       ' 发送者的邮件地址     
    .Subject     =     " Test of CDO Sending Email in asp "      ' 邮件的标题     
    .TextBody    =     " my email test ,this email is sent by cdo  "      ' 邮件的正文    
    .CC          =     ljc@oa.cccar.com.cn;sxy@cccar.com.cn    ' 抄送地址
    .Send     
  
End     With      
    
  
Set    Fields        =     Nothing      
  
Set    objMessage    =     Nothing      
  
Set    objConfig     =     Nothing      
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:设计师小姐姐 返回首页