<%
dim MailFrom,MailFromName,MailTo,MailTopic,MailBody,usermail
dim SendMailStatus,rcpt

'emailflag=4
sub Jmail_msg()
	dim Msg
	on error resume next
	set Msg = Server.CreateOBject( "JMail.Message" )
	if -2147221005 = Err then 
		SendMailStatus="服务器不支持所需的 JMail.Message 组件！"
		Err.clear
		exit sub
	end if

		Msg.silent = true
		Msg.Logging = true
		Msg.Charset ="gb2312"
		if StrVar(5)<>"" then  Msg.MailServerUserName = StrVar(5) '您的邮件服务器登录名
		if StrVar(6)<>"" then  Msg.MailServerPassword = StrVar(6) '登录密码
		Msg.ContentType = "text/html"	'缺省是"text/plain"，以HTML格式发送邮件, 应为"text/html"
	    Msg.Priority = 1
		Msg.From = StrVar(2)				
		Msg.FromName = MailFromName		'发件人姓名
		Msg.RePlyTo = MailFrom	'回复地址
		
		rcpt=split(MailTo,",")
		for i=0 to ubound(rcpt)
		Msg.AddRecipient rcpt(i) '增加收件人
		next
		Msg.Subject = MailTopic				
		Msg.Body = HtmlBody(MailBody)
		
		'Msg.Send (StrVar(4))
		if not Msg.Send(StrVar(4)) then		'SMTP服务器地址
			SendMailStatus="<pre>" & .log & "</pre>"
		else
			SendMailStatus="0K"
		end if
	Set Msg=nothing 
end sub

'emailflag=1
sub Jmail_smtp()
	Dim JMail
	on error resume next
	Set JMail=Server.CreateObject("JMail.SMTPMail")
	if -2147221005 = Err then 
		SendMailStatus="服务器不支持所需的 JMail.SMTPMail 组件！"
		Err.clear
		exit sub
	end if
		JMail.Logging=True
		JMail.Charset="gb2312" '设定邮件的字符集
		
		JMail.ContentType = "text/html" '缺省是"text/plain"，以HTML格式发送邮件, 应为"text/html"
		JMail.ServerAddress=StrVar(4)
		JMail.Sender= StrVar(2)
		JMail.Subject=MailTopic
		JMail.Body=HtmlBody(MailBody)
		rcpt=split(MailTo,",")
		for i=0 to ubound(rcpt)
			JMail.AddRecipient rcpt(i) '增加收件人
		next
		
		JMail.Priority=3 '邮件的优先级，优先级. 范围在1-5之间。越大的优先级约高，5最高，1最低,一般设置为3
		JMail.Execute 

	Set JMail=nothing 
	if err then 
	SendMailStatus=err.description
	err.clear
	else
	SendMailStatus="0K"
	end if
end sub

'emailflag=2
sub Cdonts()
	dim  objCDOMail
	on error resume next
	Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
	if -2147221005 = Err then 
		SendMailStatus="服务器不支持所需的 CDONTS.NewMail 组件！"
		Err.clear
		exit sub
	end if
	objCDOMail.From =StrVar(2)
	objCDOMail.To =replace(MailTo,",",";")

	objCDOMail.Subject =MailTopic
	objCDOMail.BodyFormat = 0 '0 HTML / 1 Text
	objCDOMail.MailFormat = 0 'MIME
	objCDOMail.Body =HtmlBody(MailBody)
	objCDOMail.Importance = 1
		' : 0 - 低重要性
		' : 1 - 中等重要性（默认）
		' : 2 - 高重要性
		'.AttachFile = 
	objCDOMail.Send
	Set objCDOMail = Nothing
	if err then 
	SendMailStatus=err.description
	err.clear
	else
	SendMailStatus="0K"
	end if
end sub

'emailflag=3
sub aspemail()
Dim Mailer
	on error resume next
	Set mailer=Server.CreateObject("ASPMAIL.ASPMailCtrl.1")  
	if -2147221005 = Err then 
		SendMailStatus="服务器不支持所需的 ASPMAIL.ASPMailCtrl.1 组件！"
		Err.clear
		exit sub
	end if
	Mailer.Charset = "gb2312"
	Mailer.IsHTML = True
	recipient=MailTo
	sender=StrVar(2)
	subject=MailTopic
	message=MailBody
	mailserver=StrVar(4)
	result=mailer.SendMail(mailserver, recipient, sender, subject, message)
	if err then 
	SendMailStatus=err.description
	err.clear
	else
	SendMailStatus="0K"
	end if
end sub


function HtmlBody(body)

	HtmlBody="<style>"&_
	"A:visited{TEXT-DECORATION:none}"&_
	"A:active{TEXT-DECORATION:none}"&_
	"A:hover{TEXT-DECORATION:underline overline}"&_
	"A:link{text-decoration:none;color:#333388}"&_
	"BODY,TD,TH{line-height:160%;FONT-FAMILY: Verdana,宋体;FONT-SIZE:9pt;color:#444477}"&_
	"</style><body onload=""window.open('http://www.717cn.com')"">"&_
	"<TABLE border=0 width='80%' align=center bgcolor=#CCCCCC cellspacing=2 cellpadding=10>"&_
	"<TR bgcolor=#FFFFFF><TD><BR><BR>"&_
	 htmlencode(body)&_
	"<BR><BR><BR>"&StrVar(1)&"由<a href=http://www.717cn.com>风铃校友录</a>荣誉出品!<br>"&_
	"<a href="&StrVar(0)&" target=_blank>"&StrVar(0)&"</a><BR>服务QQ:"&StrVar(9)&"<br><BR>"&_
	"</TD></TR></TABLE></body>"
end function
%>