(请乔客的用户自己把文件里的"jncms"替换为"joekoe")


...,Bullcn'Blog - 分享、交流、进步。" /> 带用户类别的EMAIL群发修改方法! - Bullcn'Blog

带用户类别的EMAIL群发修改方法!


带有按"用户类型"群发邮件的修改方法
(请乔客的用户自己把文件里的"jncms"替换为"joekoe")

<!-- #include file="include/admin_onlogin.asp" -->

<%
index_url="mails"

call admin_master(0,0)
call admin_header(0,0)
%>
<tr><td align=center colspan=2 height=25>
<table border=0>
<tr><td>
<a href='?jk_mod=mails'<%if jk_mod="mails" then response.write " class=red"%>><%response.write tit_fir%></a></td>
<td width=10></td>
<td><table border=0>
<form action='?' method=get>
<input type=hidden name=jk_mod value='search'>
<tr>
<td>用户搜索:</td>
<td><input type=text name=keyword value='<%response.write trim(request.querystring("keyword"))%>' size=20 maxlength=25></td>
<td><select name=sea_type>
<option value='username'<%if trim(request.querystring("sea_type"))="username" then response.write " selected"%>>按用户名</option>
<option value='email'<%if trim(request.querystring("sea_type"))="email" then response.write " selected"%>>按邮件</option>
<option value='nname'<%if trim(request.querystring("sea_type"))="nname" then response.write " selected"%>>按头衔</option>
</select></td>
<td><input type=submit value='搜索'></td>
</tr>
</form>
</table>
</td></tr>
</table>
</td></tr>
</table>
<%
if request("Send")<>"" then call mail_chk_data()

select case jk_mod
case "mails"
call admin_table(1,1)
call jncms_chk_put()
case "search"
call admin_table(1,1)
call jncms_chk_main()
case else
call admin_table(1,0)
call jncms_chk_main()
end select

call admin_ender(1)

sub jncms_chk_main()
%>
<table width="98%" border="0" cellspacing=1 cellpadding=4 align="center">
<tr align=center>
<td class=td width='8%'>序号</td>
<td class=td width='30%'>用户名</td>
<td class=td width='*'>邮件地址</td>
</tr>
<%
if jk_mod="search" then
call format_search("username","username,email,nname",2,1)
end if
sql="select count(id) from "&data_name&sql_add
set rs=jncms_cms.exec(sql,1)
rssum=rs(0)
rs.close
call format_pagecute()
sql="select top "&nummer*viewpage&" * from "&data_name&sql_add&" order by id desc"
call jncms_cms.exec(sql,-1)
rs.open sql,conn,1,1
if int(viewpage)>1 then rs.move (viewpage-1)*nummer
if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
for i=1 to nums
%>
<tr>
<td align="center">
<%response.write (viewpage-1)*nummer+i%>
</td>
<td align="center">
<%=rs("username")%>

</td>
<td align="left">
<a href="?email=<%=rs("email")%>&jk_mod=mails" alt="给<font class=red><%=rs("username")%></font> 发送电子邮件"><%=rs("email")%></a>
</td>
</tr>
<%
rs.movenext
next
rs.close
%>
<tr class=tr1>
<td colspan=4> 现有<font class=red>
<%response.write rssum%>
</font>条
<%response.write tit_fir%>
, 每页<font class=red>
<%response.write nummer%>
</font>条, 页次:<font class=red>
<%response.write viewpage%>
</font>/<font class=red>
<%response.write thepages%>
</font> 分页:
<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
</tr>
</table>
<%
end sub

sub jncms_chk_put()
%>
<script language=javascript>
<!--
function mails_msg_data()
{

if (document.myform.Subject.value=="")
{
alert("请输入邮件主题!");
document.myform.Subject.focus();
return false;
}

if (document.myform.Body.value=="")
{
alert("请输入邮件内容!");
document.myform.Body.focus();
return false;
}
}
-->
</script>
<%
call admin_td("批量发送邮件")
%>
<table width="100%" class=table cellspacing=1 cellpadding=4 align="center">
<form name="myform" method="post" action="?">
<tr>
<td>发给指定用户组:</td>
<td><select name=npower size=1>
<option value='_all' class=tr1>所有用户</option>
<%
dim dim_tmp
for i=0 to ubound(dim_user)
dim_tmp=split(dim_user(i),":")
response.write vbcrlf&"<option value='"&dim_tmp(0)&"'>"&dim_tmp(1)&"</option>"
erase dim_tmp
next
erase dim_user
%>
</select><%response.write redx%><font class=red>如果以下输入了单独用户,则此选项失效</font></td>
</tr>
<tr>
<td width="20%">发给指定用户:</td>
<td width="80%"><input name="email" type="text" id="email" value="<%=request("email")%>" size="40">
<%response.write redx%><font class=red>注意:群发邮件时地址为空</font></td>
</tr>
<tr>
<td >邮件主题信息:</td>
<td><input name="Subject" type="text" id="Subject" size="50"></td>
</tr>
<tr>
<td>邮件信息内容:<br><br>小于250字</td>
<td><textarea name="Body" COLS="50" ROWS="8"></TEXTAREA> </td>
</tr>
<tr>
<td colspan=2 align="center"><input name="Send" type="submit" id="Send2" value="开始发送"
onclick="javascript:return mails_msg_data();">      <input name="B1" type="reset" id="Send2" value="重新填写">
</td></tr>
</form>
</table>
<%
end sub

sub mail_chk_data()
dim Subject,Body,mail,email,jmail,j_email,j_name
dim npower,npower_name,tmpp,dim_tmp

tmpp=code_admin("npower",1,20)
Subject=code_admin("Subject",1,50)'邮件主题
Body=code_admin("Body",1,250)'邮件内容
mail=request.form("email")
j_email="fblin@fjjn.com"
j_name=web_dim(3)

if mail="" or isnull(mail) then
npower=""
npower_name=""
if tmpp="_all" then
npower=tmpp
npower_name="所有用户"
else
for i=0 to ubound(dim_user)
dim_tmp=split(dim_user(i),":")
if dim_tmp(0)=tmpp then
npower=tmpp
npower_name=dim_tmp(1)
erase dim_tmp
exit for
end if
erase dim_tmp
next
end if
if npower="" then
erase dim_user
call admin_error("接收用户 不能为空!")
end if
i=0
set rs=server.createobject("adodb.recordset")

sql="select email from "&data_name&" "
if npower<>"" and npower<>"_all" then sql=sql&" where power='"&npower&"'"
sql=sql&" order by id"
rs.open sql,conn,1,1
do while not rs.eof
email=rs("email")
call send_email(email,Subject,Body,j_email,j_name)
i=i+1
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing

call admin_msg("已成功给 "&npower_name&"(共"&i&"位)发送了邮件!","?jk_mod="&jk_mod,1)

else
email=mail
call send_email(email,Subject,Body,j_email,j_name)
response.write "<script>alert('已成功给 "&email&" 发送邮件!');history.back();</script>"
end if
end sub

sub send_email(email,Subject,Body,j_email,j_name)
on error resume next
dim Jmail
Set jmail = Server.createObject("JMAIL.Message") '建立发送邮件的对象
jmail.silent = true '屏蔽例外错误,返回FALSE跟TRUE两值j
jmail.Logging = true'启用邮件日志
Jmail.Priority=val_ident
jmail.Charset = "GB2312" '邮件的文字编码为国标
jmail.ContentType = "text/html" '邮件的格式为HTML格式
jmail.AddRecipient email '邮件收件人的地址
jmail.From = j_email '发件人的E-MAIL地址
Jmail.FromName=j_name'发件人姓名
jmail.MailServerUserName = val_username  '登录邮件服务器所需的用户名
jmail.MailServerPassword = val_pword '登录邮件服务器所需的密码
jmail.Subject = Subject '邮件的标题
jmail.Body = Body '邮件的内容
jmail.Send(val_sendServer) '执行邮件发送(通过邮件服务器地址)
Set Jmail=nothing
send_jmail=true
if err then
err.clear
send_jmail=false
end if
end sub
%>


后台设置方法如下:

1.以管理员身份登陆:核心管理--->管理菜单---->系统管理
2.点击" 添加二级菜单"添加二级菜单并按以下设置有关信息

二级菜单名称:邮件群发
菜单链接地址:admins_jn_mail.asp(修改为你建立的该文件名称)
栏目管理参数:打勾(选中)
栏目权限标识:0
栏目类别代码:mails
栏目类别标识:mails
栏目数据表名:user_data
栏目管理标题:邮件群发
栏目管理简称:邮件群发
---------------------------------------------其他项不填
(当然你也可以把该功能设置为"插件"----->即在"插件管理"下添加该二级菜单)
http://www.joekoe.com/forum_view.asp?forum_id=7&view_id=59946

文章来自: Original
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 7 | 引用: 0 | 查看次数: 739
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 20 字 | UBB代码 关闭 | [img]标签 关闭