<%

server.scripttimeout=99999
' 
'Send_From:	 
'Send_To:	 
'Send_Subject:	
'Send_Body:	
'Send_Master:	
'Send_Uid:	
'Send_pwd:	
'Send_Saddr:	
'Send_pri:	
function Sendmail(Send_Subject,Send_Body,email)
	conndb
	on error resume next
	set rsmail=server.createobject("adodb.recordset")
	sql="select * from Web_MailConfig where MC_FLAG=1 "     
	rsmail.open sql,conn,1,3
	 	FromMail=rsmail("MC_SysMail")
	 	FromName=rsmail("MC_Manager")
	 	MailUsername=rsmail("MC_EmailUid")
	 	MailPassword=rsmail("MC_EmailPwd")
	 	MailSmtp=rsmail("MC_MailServer")
	rsmail.close : set rsmail=nothing
	MailtoAddress=email
	isHtml=true
	Priority=3
	if   JmailSend(Send_Subject,Send_Body,isHtml,Priority,MailtoAddress,MailtoName,FromMail,FromName,MailSmtp,MailUsername,MailPassword)=true then
		Sendmail=true	
	else
		Sendmail=false
        end if 
End function

'================================================= 
'函数名：JmailSend 
'作 用：用Jmail发送邮件 
'参 数：Subject 邮件标题 
' MailBody 邮件内容 
' isHtml 是否发送Html格式邮件 (true 是) 
' MailTo 收件人Email 
' From 发件人Email
' FromName 发件人姓名
' MailPriority 邮件等级，1为加急，3为普通，5为低级
' MailtoAddress 收件人地址
' MailtoName  收件人
' FromMail 发件人邮件
' FromName  发件人
' MailSmtp smtp服务器
' MailUsername 邮箱用户名
' MailPassword邮箱密码
'返回值："N" 发送失败　"Y" 发送成功 
'================================================= 
function JmailSend(Subject,MailBody,isHtml,Priority,MailtoAddress,MailtoName,FromMail,FromName,MailSmtp,MailUsername,MailPassword)
	dim JmailMsg 
	on error resume next
	set JmailMsg=Server.CreateObject("JMail.Message")
	if err then
		alert "服务器没有安装JMail组件","back"
		err.clear
		exit function
	end if
	JmailMsg.mailserverusername=MailUsername 
	JmailMsg.mailserverpassword=MailPassword 
	If MailtoName<>"" then
		JmailMsg.AddRecipient MailtoAddress,MailtoName     '收信人
	Else
		JmailMsg.AddRecipient MailtoAddress
	End If 
	JmailMsg.from=FromMail
	If FromName<>"" then
		JmailMsg.fromname=FromName
	End if
	JmailMsg.Charset="gb2312" 
	JmailMsg.Logging=true 
	'JmailMsg.isHtml=true
	JmailMsg.silent=true
	JmailMsg.Priority=Priority          '邮件等级，1为加急，3为普通，5为低级
	JmailMsg.subject=Subject 
	'JmailMsg.body=MailBody
	jmailMsg.HTMLBody = "<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""></head>"
	jmailMsg.appendHTML "<body>"
	jmailMsg.appendHTML MailBody
	jmailMsg.appendHTML "</body></html>"
	JMailMsg.Body = "我们使用了HTML格式，但您的查看软件可能不支持"

	if not JmailMsg.send(MailSmtp) then 
		JmailSend=false
	else 
		JmailSend=true
	end if 
	JmailMsg.close 
	set JmailMsg=nothing 
end function 

function Cdonts(Subject,MailBody,isHtml,Priority,MailtoAddress,MailtoName,FromMail,FromName,MailSmtp,MailUsername,MailPassword)
	dim MailObject 
	on error resume next
	Set MailObject = Server.CreateObject("CDONTS.NewMail")
	if err then
		alert "服务器没有安装Cdonts组件","back"
		err.clear
		exit function
	end if
		if Priority="1" then
			Priority=0
		elseif Priority="3" then
			Priority=1
		elseif Priority="5" then
			Priority=2
		end if
		MailObject.From = FromMail
		MailObject.To = MailtoAddress
		MailObject.Subject = Subject
		MailObject.BodyFormat = 1 
		MailObject.MailFormat = 0 
		MailObject.Body = MailBody
		MailObject.Importance=Priority
		MailObject.Send
		If Err<>0 Then
			Cdonts=false
		Else
			Cdonts=true
		End If
		MailObject.close 
		set MailObject=nothing 
	End function

function Aspemail(Subject,MailBody,isHtml,Priority,MailtoAddress,MailtoName,FromMail,FromName,MailSmtp,MailUsername,MailPassword)
	dim MailObject 
	on error resume next
	Set MailObject = Server.CreateObject("Persits.MailSender")
	if err then
		alert "服务器没有安装Aspemail组件","back"
		err.clear
		exit function
	end if

		MailObject.Charset = "gb2312"
		MailObject.IsHTML = false
		MailObject.username = MailUsername	'服务器上有效的用户名
		MailObject.password = MailPassword	'服务器上有效的密码
		MailObject.Priority = Priority
		MailObject.Host = MailSmtp
		'Obj.Port = 25			' 该项可选.端口25是默认值
		MailObject.From = FromMail
		If FromName<>"" Then
			MailObject.FromName = FromName	' 该项可选
			MailObject.AddAddress MailtoAddress,FromName
		Else
			MailObject.AddAddress MailtoAddress
		End if
		MailObject.Subject = Subject
		MailObject.Body = MailBody
		MailObject.Send
		If Err<>0 Then
			Aspemail=false
		Else
			Aspemail=true
		End If
		MailObject.close 
		set MailObject=nothing 
	End function

%> 

 
 

