无组件用ASP发送邮件

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

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

%>
-->

 

上面两段ASP可以放在一个send.asp中,然后在邮件内容书写页的form里把action设为send.asp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值