请选择 进入手机版 | 继续访问电脑版

程序人生

 找回密码
 注册

QQ登录

只需一步,快速开始

程序人生 门户 ASP程序开发 查看内容

再介绍一种ASP发邮件方法

2011-6-19 17:26| 发布者: admin| 查看: 841| 评论: 0|来自: 百度整理

摘要: 不用安装也可以,看下面,使用方式最下面 % class sentmail 'var sendmail test,emptyvar 'creat by qqlxinye@tom.com 'time 2008-09-19 'qq:273453129 'web www.qqlxinye.cn dim outSmtp,outUser,outPsd,recUser,re ...
不用安装也可以,看下面,使用方式最下面


<%
class sentmail
'var sendmail test,emptyvar
'creat by qqlxinye@tom.com
'time 2008-09-19
'qq:273453129
'web www.qqlxinye.cn

dim outSmtp,outUser,outPsd,recUser,recSubmit,bodyContent,AddAttachment,ifsend
 function init_mail(str1,str2,str3,str4,str5,str6,str7)
  outSmtp=str1
  outUser=str2
  outPsd=str3
  recUser=str4
  recSubmit=str5
  bodyContent=str6
  AddAttachment=str7
  if isnull(outSmtp)or isnull(outUser)or isnull(outPsd) or isnull(recUser) or isnull(recSubmit) or isnull(bodyContent)  then
   ifsend=false
  end if
 end function
 function send()
  if not ifsend then
   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) =outSmtp
  .Item(cdoSMTPServerPort) = 25 
  .Item(cdoSMTPConnectionTimeout) = 10 
  .Item(cdoSMTPAuthenticate) = cdoBasic 
  .Item(cdoSendUserName) = outUser
  .Item(cdoSendPassword) = outPsd
  .Update 
  End With 
  
  Set objMessage = Server.CreateObject("CDO.Message") 
  Set objMessage.Configuration = objConfig 
  On Error Resume Next 
   With objMessage 
   .To =recUser
   .From =outUser
   .Subject = recSubmit
   '.TextBody = bodyContent
   .HTMLBody=bodyContent
   '.AddAttachment "C:\Scripts\Output.txt"'邮件附件 
   .Send 
   End With 
  On Error GoTo 0
  
  if err.description<>""then
  response.Write "aaa"
  end if
    
  Set Fields = Nothing 
  Set objMessage = Nothing 
  Set objConfig = Nothing
  end if
 end function 
end class
%> 
<!--发送测试代码
set mail=new sentmail
mail.init_mail "smtp 服务器","smtp 服务器上的邮箱","smtp 服务器上的邮箱的密码","收信人地址","主题","正文内容",null
null这参数暂时不用,但发送时还是要写上,共7个参数
mail.send
<%
set mail=new sentmail
mail.init_mail "smtp.tom.com","qqlxinye@qq.com","123456","273453129@qq.com","test","<html><body><p align='center'><b>Hey 'there!</b></p><p align='center'><b>This is a html doc in your Email!!!!</b></p><p align='center'> </p><p align='center'>' </p><p align='center'><i><u>We kick the Llamas Ass!!!!</u></i></p></body></html>","<font color=red>test</font>"
mail.send

%> 
-->

鲜花

握手

雷人

路过

鸡蛋

相关阅读

最新评论


关于程序人生网|小黑屋|手机版|Archiver|

程序人生 | QQ

粤公网安备 44040202000007号

( 粤ICP备13038131号-5 )

返回顶部