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

'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
	With Msg
		.silent = true
		.Logging = true
		.Charset ="gb2312"
		.ContentType = "text/html"	'缺省是"text/plain"，以HTML格式发送邮件, 应为"text/html"
		.From = MailFrom				
		.FromName = MailFromName		'发件人姓名
		.RePlyTo = MailFrom	'回复地址
		rcpt=split(MailTo,",")
		for i=0 to ubound(rcpt)
			.AddRecipient rcpt(i) '增加收件人
		next
		.Subject = MailTopic				
		.Body = HtmlBody(MailBody)
		'.AppendText(textYouWantToAppend)
		if StrVar(5)<>"" then	.MailServerUserName = StrVar(5) '您的邮件服务器登录名
		if StrVar(6)<>"" then .MailServerPassword = StrVar(6) '登录密码
		if not .Send(StrVar(4)) then		'SMTP服务器地址
			SendMailStatus="<pre>" & .log & "</pre>"
		else
			SendMailStatus="0K"
		end if	
	End With
	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
	With JMail
		.Logging=True
		.Charset="gb2312" '设定邮件的字符集
		.ContentType = "text/html" '缺省是"text/plain"，以HTML格式发送邮件, 应为"text/html"
		.ServerAddress=StrVar(4)
		.Sender=MailFrom
		.Subject=MailTopic
		.Body=HtmlBody(MailBody)
		rcpt=split(MailTo,",")
		for i=0 to ubound(rcpt)
			.AddRecipient rcpt(i) '增加收件人
		next
		'.AddRecipientBCC mailBCC '增加密件收件人
		'.AddRecipientCC mailCC '增加抄送收件人
		.Priority=3 '邮件的优先级，优先级. 范围在1-5之间。越大的优先级约高，5最高，1最低,一般设置为3
		.Execute 
	End With
	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
	With objCDOMail
		.From =MailFrom
		.To =replace(MailTo,",",";")
		rem .Cc =MailCc
		rem .Bcc =MailBcc
		.Subject =MailTopic
		.BodyFormat = 0 '0 HTML / 1 Text
		.MailFormat = 0 'MIME
		.Body =HtmlBody(MailBody)
		.Importance = 1
		' : 0 - 低重要性
		' : 1 - 中等重要性（默认）
		' : 2 - 高重要性
		'.AttachFile = 
		.Send
	End With
	Set objCDOMail = Nothing
	if err then 
	SendMailStatus=err.description
	err.clear
	else
	SendMailStatus="0K"
	end if
end sub

'emailflag=3
sub aspemail()
	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
	recipient=MailTo
	sender=MailFrom
	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://txlbbs.126.com')"">"&_
	"<TABLE border=0 width='80%' align=center bgcolor="&TableBorderColor&" cellspacing=2 cellpadding=10>"&_
	"<TR bgcolor="&LightTBColor&"><TD><BR><BR>"&_
	 htmlencode(body)&_
	"<BR><BR><BR>风华同学录由<a href=mailto:zjgxwx@163.com>风华工作室</a>荣誉出品!<br>"&_
	"<a href=http://txlbbs.126.com target=_blank>http://txlbbs.126.com</a><br><BR>"&_
	"</TD></TR></TABLE>"

end function
%>