sendmail.asp

来自「1. 硬件环境:MS WINDOWS NT PACK 4 OR LATER /W」· ASP 代码 · 共 174 行

ASP
174
字号
<!-- #include file="setup.asp" -->
<!-- #include file="inc/upfile.asp" -->
<!-- #include file="inc/function.asp" -->
<%
Server.ScriptTimeout=10000
Call Top
Call table()
validate "Login.asp",5
Response.Write("<style><!--	TABLE{BORDER-TOP:0px;BORDER-LEFT:0px;BORDER-BOTTOM:1px}TD{BORDER-RIGHT:0px;BORDER-TOP:0px}--></style><br>")
if Request.ServerVariables("request_method") = "POST" then
se=Trim(Request.Form("se"))
Tto=Trim(Request.Form("MM"))
subject=Trim(Request.Form("subject"))
mail_body=Trim(Request.Form("mail_body"))
selectT=Trim(Request.Form("selectT"))
radiobutton=Trim(Request.Form("radiobutton"))
if subject="" Then subject="(无!)"
BadMsg=""
if Not IsValidEmail(se) Then BadMsg=BadMsg&"发件人的Email地址输入不正确,邮件无法送出!\n"
if Tto="" Then BadMsg=BadMsg&"收件人的Email地址输入不正确,邮件无法送出!\n"
if mail_body="" Then BadMsg=BadMsg&"请输入邮件内容!"
if badMsg <> "" Then Error 2,"邮件发送失败!\n\n"&BadMsg,""
BadMsg=""


body=""
body=body&"你好,以下是来自"&Community&"的信息!"&vbCrlf
body=body&"---------------------------------------------"&vbCrlf
body=body&mail_body&vbCrlf
body=body&"---------------------------------------------"&vbCrlf
body=body&"此为Shopii电子商务系统自动发出的邮件!请勿回复!"&vbCrlf
body=body&"发送时间:"&now&vbCrlf
body=body&"程序制作:Copyright &copy; 2002 - 2005 ShopII.com Yuzi工作室 版权所有"


if IsObjInstalled("CDONTS.NewMail") Then
  if radiobutton="Other" Then
	mmail=split(Tto,",")
	for i=0 to ubound(mmail)
	sendmail(mmail(i))
	next
  else
    sql="Select UserEmail_1 From UserInfo where DelThis = False"
    Set rs = Conn.Execute(sql)
	do while not rs.eof
	'if Trim(Rs("UserEmail_1"))<>"" and IsValidEmail(Rs("UserEmail_1"))=true Then s=s&Rs("UserEmail_1")
	if Trim(Rs("UserEmail_1"))<>"" Then sendmail(Rs("UserEmail_1"))
	rs.movenext
	loop
	Rs.Close
	Set Rs = Nothing
  end if  
Elseif IsObjInstalled("JMail.Message") Then

Mai1 = Trim(conn.execute("Select FunctionInfo from Functions where FunctionID=26")(0))
Mai2 = Trim(conn.execute("Select FunctionInfo from Functions where FunctionID=27")(0))
Mai3 = Trim(conn.execute("Select FunctionInfo from Functions where FunctionID=28")(0))

  if radiobutton="Other" Then
	mmail=split(Tto,",")
	for i=0 to ubound(mmail)
	if IsValidEmail(mmail(i)) Then JaJmail(mmail(i))
	next
  else
	sql="Select UserEmail_1 From UserInfo where DelThis = False"
    Set Rs = Conn.Execute(sql)
	do while not rs.eof
	'if Trim(Rs("UserEmail_1"))<>"" Then JJmail=JJmail&Rs("UserEmail_1")&"<br>"
	if Trim(Rs("UserEmail_1")) <>"" Then JaJmail(Rs("UserEmail_1"))
	rs.movenext
	loop
	Rs.Close
  end if
Else
  Error 2,"邮件发送失败!\n您的空间没有适合的Email发送组件!",""
End if


Error 3,"邮件成功发送!","sendmail.asp"
end if%>
<script language="JavaScript">
function ThisUs(){
document.form1.MM.value = "发送给商城所有注册会员!";
}
function ThisUs1(){
document.form1.MM.disabled = false;
}
</script>		
</head>
<body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">

	
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
<form name=form1 method="post">

  
<tr><td height="20" align="left"  width="79">发送选项: </td><td height="20" class="enbold" align="left" colspan="3">指定Email:<input type="radio" name="radiobutton" value="Other" checked Onclick="JavaScript:ThisUs1()"> | 所有注册会员:<input type="radio" name="radiobutton" value="AllUser" Onclick="JavaScript:ThisUs()"></td></tr>

<tr><td height="20" align="left"  width="79">发件人: </td><td height="20" class="enbold" align="left" colspan="3"><input name="se" type="text"  id="se" style="border:1 solid #000000; font-size:9pt; overflow:no;"  value="<%=conn.execute("Select FunctionInfo from Functions where FunctionID=26")(0)%>" size="52"></td></tr>
<tr><td height="20" align="left"  width="79">收件人: </td><td height="20" colspan="3"><input type="text" name="MM" size="52" style="border:1 solid #000000; font-size:9pt; overflow:no;" value=""> 多个Email请用","分隔!</td>
</tr><tr> 
<td height="18" align="left" >标 题 : </td>
<td height="18" colspan="3"> 
<input type="text" name="subject" size="52" style="border:1 solid #000000; font-size:9pt; overflow:no;" value=""></td>
</tr><tr> 
<td colspan="4"><textarea name="mail_body" style="border:1 solid #000000; font-size:9pt; overflow:auto; width:100% height=200;" cols=90 rows="7" ></textarea></td>	
<td width="1"></td>
</tr><tr> 
<td height="30" align="left" >&nbsp;<input type="image"  src="images/send.gif" name="Submit3" value="Submit"></td>
<td width="298" height="30" align="left" >&nbsp;</td>
<td width="4" height="30" align="left" >&nbsp; 
</td>
<td width="233" height="30" colspan="1" align="left" ><div align="right">优先级别 
<select name="selectT" >
<option value="3">普通</option>
<option value="1">紧急</option>
<option value="5" selected>缓慢</option>
</select>
</div></td>
</tr>
</form>
</table>

    
<table width="80%" border="0" cellspacing="0" cellpadding="0" align=center>
<tr valign="middle"> 
<td height="30" width="301"  valign="middle">添加附件 
<input type="file" name="uploaded_file" size="20"  style="border:1 solid #000000; font-size:9pt; overflow:no;"></td>
<td width="157" >&nbsp;(最多10个)</td>
<td height="30" width="149" valign="middle" align="left"> <input name="image" type="image" src="images/attachment.gif" width="80" height="21" border="0"></td>

</tr>

</table>
<table width="80%" border="0" cellspacing="0" cellpadding="0" align=center>

<tr valign="middle" height="30"><td width="149" height="30" > 共 <input type="text" name="textfield" style="border:1 solid #000000; font-size:9pt; overflow:no;" size="5" maxlength="5"  value="0">bytes</td>
<td width="301" height="35" align="center" > 
<select name="remove"  style="border:1 solid #000000; font-size:9pt; overflow:auto;">
<option>--没有附件--</option>
</select></td><td width="178" height="30" align="left"> 
<input type="image" border="0" name="removeatt" src="images/deleteattachments.gif" width="105" height="21">
</td>
</tr>
</table>
</body>
</html>
<%htmlend



Sub sendmail(Tmail)
  Set myMail=Server.CreateObject("CDONTS.NewMail")
  myMail.From =se
  myMail.To = Tmail
  myMail.Subject = subject
  myMail.Body =body
  myMail.Send
  Set myMail=Nothing
End Sub

Sub JaJmail(Tmail)
  Set JMail=Server.CreateObject("JMail.Message")
  JMail.AddRecipient Tmail
  JMail.Subject = subject
  JMail.Body = body
  JMail.From = se
  JMail.MailServerUserName = Mai1
  JMail.MailServerPassword = Mai2
  JMail.Send Mai3
  JMail.Priority=selectT                               			 '1: 最高优先级.2:高 3:普通 4:低 5:最低
  Set JMail=Nothing
End Sub%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?