<%
dim MailSub,MailBody,isHtml,HtmlBody,MailTo,From,FromName,SmtpSever,Account,Password,SendResult
MailTo  = trim(request.form("hd-zj888@163.com"))
MailSub = trim(request.form("subject"))
Account = trim(request.form("hd-zj888"))
Password= trim(request.form("001718"))

if request.form("isHtml") = "true" then
    MailBody = "这是一封Html格式的邮件，但您的客户端不支持，请访问http://www.upsdn.net获取相关信息"
    HtmlBody = request.form("mess")
    isHtml   = TRUE
else
    MailBody = request.form("mess")  
end if
      
From    = trim(request.form("from"))
FromName= trim(request.form("FromName"))
SmtpServer = trim(request.form("server"))


if MailTo="" or MailSub="" or Account ="" or Password ="" or From ="" or FromName="" or SmtpServer="" then
  response.write "<font color=red>项目请填写完全</font>"
else
  SendResult=JMailSend(MailSub,MailBody,isHtml,HtmlBody,MailTo,From,FromName,Smtp,Account,Password)
  if SendResult=TRUE then
    response.write "<br><font color=blue>发送成功</font>"
  else
    response.write "<br><font color=red>发送失败</font>"
  end if    
end if  
%>
<%
function JMailSend(Subject,Body,isHtml,HtmlBody,MailTo,From,FromName,Smtp,Username,Password)
  dim objJMail
  set objJMail=Server.CreateObject("Jmail.Message")
  
  objJMail.Logging=TRUE            'Enable Log
  objJMail.Silent=TRUE             'Dont throw any exceptions,only return TRUE or FALSE
  objJMail.Priority=2
  'objJMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
  objJMail.Charset="gb2312"        'Simplied Chinese
  objJMail.ContentTransferEncoding = "base64"     'The default is "Quoted-Printable"
  'objJmail.ISOEncodeHeaders = False
  
  objJMail.MailServerUserName=Username
  objJMail.MailServerPassword=Password
 
  objJMail.AddRecipient MailTo
  'objJMail.AddRecipientBCC Email  
  'objJMail.AddRecipientCC Email  
  objJMail.From=From
  objJMail.FromName=FromName
  'objJMail.ReplyTo
  objJMail.Subject=Subject
  objJMail.Body=Body
  if isHtml=true then 
    objJMail.htmlbody=HtmlBody
  end if  
  
  'objJMail.AddAttachment(filename, True)  'TRUE=inline
 
  if not objJMail.Send(Smtp) then
      JmailSend=FALSE
      Response.Write "Error Code:"&objJMail.ErrorCode
      Response.Write "<br>Error Message:<br><font color=red>"&objJMail.ErrorMessage&"</font><br>"
      Response.Write "Error Source:<br><font color=blue>"&objJMail.ErrorSource&"</font><br>"
      Response.Write "Log:<br>"&objJMail.Log
  else
      JmailSend=TRUE
  end if
  objJMail.close
  set objJMail=nothing
end function  
%>