Jmail发信实例,可直接调用~!

发表于:2007-06-30来源:作者:点击数: 标签:
!--jmail.asp-- script language= VB Script runat=server function SendMail(SMTPServer,sender,mailto,subject,msg)@#这个是一个函数,在程序中可以直接调用。 dim JMail @#on error resume next @#等待功能扩充 Set JMail = Server.CreateObject(JMail.SMT
<!--jmail.asp-->
<script language=VBScript runat=server>
   function SendMail(SMTPServer,sender,mailto,subject,msg)@#这个是一个函数,在程序中可以直接调用。
       dim JMail
       @#on error resume next
       @#等待功能扩充
       Set JMail = Server.CreateObject("JMail.SMTPMail")
       JMail.LazySend = true    @#这个属性是将邮件放入缓冲直至发出为止,的不到任何的错误信息
       JMail.Charset = "euc-kr" @#设定邮件的字符集,默认为"US-ASCII" 一般中文用"gb2312"
       JMail.ContentType = "text/html" @#这个邮件的头设置, 默认为 "text/plain" 能设置成你需要的任何情况。                                                   @#你想发送HTML信息,改这个头文件为 "text/html"
       JMail.ServerAddress =SMTPServer @#SERVER的地址。可以有很多的SERVER地址,后可跟端口号
       JMail.Sender = sender@#邮寄的地址
       JMail.Subject = subject@#邮件的标题。

       JMail.AddRecipient mailto@#加入一个收件者
    
       JMail.Body = msg @#UBBCode(htmlencode(MSG))E-Mail的主体

       JMail.Priority = 1@#邮件的优先级,可以范围从1到5。越大的优先级约高,比如,5最高,1最低,一般设置为3


       JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")@#addheader加入一个头信息
                                                                               @#remote_addr发出请求的机器的IP地址   
       JMail.Execute@#执行邮件发送到SERVER
       set jMail=nothing       
       if err then    @#检测
            SendMail=err.description
            err.clear
       else
            SendMail="OK"
       end if
   end function
</script>

<%
    @#调用说明:
    strHTML = "<table width=""80%"" border=""1"">" &chr(13) &chr(10) @#这里需要加上两个"
    strHTML = strHTML & " <tr>" &chr(13) &chr(10) @#chr(13)硬回车chr(10)软回车
    strHTML = strHTML & "<td align=""center"" valign=""middle"">HELLO~!</td>" &chr(13) &chr(10)
    strHTML = strHTML & "</tr>" &chr(13) &chr(10)
    strHTML = strHTML & "</table>"

    smtpserver="mail.sh163.net:25"
    sender="juliet@sh163.net"
    subject="HEY!"
    msg="<HTML><BODY><CENTER>" & strHTML & "</CENTER></BODY></HTML>"
    mailto=email@#收信人email

    call SendMail(SMTPServer,sender,mailto,subject,msg)@#调用函数
%>

原文转自:http://www.ltesting.net