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         
=     " [email protected] "       ' 接收者的邮件地址     
    .From        =     " [email protected] "       ' 发送者的邮件地址     
    .Subject     =     " Test of CDO Sending Email in asp "      ' 邮件的标题     
    .TextBody    =     " my email test ,this email is sent by cdo  "      ' 邮件的正文    
    .CC          =     [email protected];[email protected]    ' 抄送地址
    .Send     
  
End     With      
    
  
Set    Fields        =     Nothing      
  
Set    objMessage    =     Nothing      
  
Set    objConfig     =     Nothing      

你可能感兴趣的:(服务器,asp)