注册 登录
编程论坛 ASP技术论坛

[求助]不同邮件标题、内容与不同邮箱一对一群发问题

发布于 2010-05-03 21:39, 253 次点击
思路:
通过<input name='ID' type='checkbox'  id="ID" value='<% response.Write cstr(RsList("ID"))%>'>传递id给sendmail.asp;
要发送的email地址、邮箱标题与发送的内容一一对应;
最终要达到的效果:<input name='ID' type='checkbox'  id="ID" value='<% response.Write cstr(RsList("ID"))%>'>多选发送邮件。
现在代码问题:只有最后一项是一对一发送,而之前的邮件内容却是循环不同次数再发送。
代码如下:
<!--#include file="../inc/func.asp" -->
<%
'CheckSession
set conn=server.CreateObject("ADODB.Connection")
conn.open GetConnectionString


dim rs : set rs = server.CreateObject("adodb.recordset")
sql = "select * from tb_paperBuy "
if request("id") <> "" then sql = sql & " where id in (" & request("id") & ")"

rs.Open sql,conn,1,1
'''''''''数据库连接'''''''''''''''''
%>

<%

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set jmail = Server.CreateObject("JMAIL.Message")

do while not rs.EOF
     
     papertype = rs("paperid")
     
          set hxrs = server.CreateObject("adodb.recordset")
          sql="select top 1 *  from tb_paper where papertype= '"&papertype&"' and deleted = 0 order by publishdate desc"
          hxrs.Open sql,conn,1,1
          if not hxrs.EOF then
            folderStr = hxrs("folder")
            PhotoStr = folderStr &"/b_page_01.jpg"
            idStr = hxrs("id")
            trsFilePathStr = folderStr &"/index.htm"
            PaperNameStr = hxrs("PaperName")
          end if
        
    mailbody=mailbody &"<style>.link {  font-size: 12px; color: #000000; text-decoration: none; line-height: 24px}"
    mailbody=mailbody &".border {  border: 1px #CBCBCB solid}"
    mailbody=mailbody &".bliak {  font-size: 13px; font-weight: bold; color: #000000; text-decoration: none;border-bottom: 1px #CBCBCB solid;}"
    mailbody=mailbody &".copy {  font-size: 12px; color: #343434; text-decoration: none}"
    mailbody=mailbody &"</style>"
    mailbody=mailbody &"<table width='610' border='0' cellspacing='0' cellpadding='0' align='center'><tr><td width='610'>"
     
    mailbody=mailbody &"<table width='96%' border='0' cellspacing='0' cellpadding='0' align='center'> <tr>"
    mailbody=mailbody &"<td class='link' height='24'>尊敬的读者:</td>"
    mailbody=mailbody &"</tr>"
    mailbody=mailbody &"<tr>"
    mailbody=mailbody &"<td height='40'><span class='link'>&nbsp; &nbsp; 您好!最新一期的<b><font color='#0000FF'> "&hxrs("papername")&" </font></b>已出版,现将这一期<b><font color='#0000FF'> "&hxrs("papername")&" </font></b>主要内容和地址发送给您,您点击就可以阅读了!</span>"
    mailbody=mailbody &"</td></tr></table>"
    mailbody=mailbody &"</td></tr>"
    mailbody=mailbody &"<tr><td width='610'>"
    mailbody=mailbody &"<table width='98%' border='0' cellspacing='3' cellpadding='0' align='center'><tr><td width='59%'> "
    mailbody=mailbody &"<table width='95%' border='0' cellspacing='0' cellpadding='0' class='border'><tr><td>"               
    mailbody=mailbody &"<a href='http://192.168.1.218/"&trsFilePathStr&"' target='_blank'>"
    mailbody=mailbody &"<img src='http://192.168.1.218/"&PhotoStr&"' width='336' height='520' border='0'></a></td></tr></table>"
    mailbody=mailbody &"</td><td width='39%' valign='top'>"                     
    mailbody=mailbody &"<table width='98%' border='0' cellspacing='1' cellpadding='0' align='center'><tr style= 'padding-bottom:5px'>"
    mailbody=mailbody &"<td height='20' class='bliak' colspan='3'>&nbsp;"&FormatDateTime(hxrs("publishdate"), 1)&" <font color='#AB0500'>部分目录</font></td></tr>"
              
              set listrs = server.CreateObject("adodb.recordset")
              sql="select top 20 *   from tb_article where paperid = "&idStr&" and deleted = 0 and audited =0 and title <> '广告'  order by verorder asc"
              listrs.Open sql,conn,1,1
              'response.Write sql
              do while not listrs.EOF
              listrsStr = listrs("title")
              htmlurlStr = listrs("htmlurl")
            
        mailbody=mailbody &"<tr><td height='3' width='17'>&nbsp;</td><td height='3' width='14'>◇</td>"                                
        mailbody=mailbody &"<td height='3' width='250'>&nbsp;<a href='http://192.168.1.218/"&htmlurlStr&"' target='_blank' class='link'>"&left(listrsStr,16)&"</a></td></tr>"
              
              listrs.MoveNext
              loop
              hxrs.close
              set hxrs = nothing
              listrs.close
              set listrs = nothing
              
        mailbody=mailbody &"</table></td></tr></table>"
        mailbody=mailbody &"</td></tr></table>"   
        
        sendmail PaperNameStr,rs("email"),mailbody
        
rs.movenext
loop

jmail.Close()
Set jmail=Nothing


Sub sendmail(mailtitle,mailurl,mailcontent) '标题,邮件地址,邮件内容
Set jmail = Server.CreateObject("JMAIL.Message")
jmail.logging = False
jmail.Silent = True '为TRUE的话可返回邮件是否发送成功
jmail.Charset = "GB2312"
jmail.ContentType = "text/html"
jmail.AddRecipientBCC mailurl '邮件地址
jmail.From = " " '这里是发送邮件的地址,接收的信箱显示
jmail.FromName= "广播电视报社" '邮件发送者姓名
jmail.MailServerUserName = " " '发邮件的地址,这里最好和jmail.from保持一致,否则有的邮件服务器会发不出去。
jmail.MailServerPassword = " " '这里是上面那个邮箱密码
jmail.Subject = mailtitle '邮件标题
jmail.htmlBody = mailcontent '邮件内容
jmail.send("smtp.)
jmail.ClearRecipients() '清空已经发送到邮件列表
End Sub

if Err then      
     Response.write "<script>alert('错误号:"&err.number&"  描述:"&err.description&"');location.href='onlineFile_List.asp';</script>"
     Err.Clear
     Else     
     Response.Write "<script>alert('发送成功');location.href='onlineFile_List.asp';</script>"
     End If
%>
不知此段代码问题出在哪里?或者哪位高手有现成的不同邮件内容分别群发的例子,以供借鉴。一般的jmail群发是,同一内容发给不同邮箱。我想知道的是,不同邮箱分别是不同的内容,怎样群发?

[ 本帖最后由 ly0419 于 2010-5-3 21:47 编辑 ]
0 回复
1