Click to See Complete Forum and Search --> : Email Problem


fvillena
09-30-2003, 09:36 AM
Hi Everyone

I have a page that sends an email of database driven content to a subsription list which is also taken from a database.

The problem is that after the first email is sent, the message duplicates itself each time it goes through the loop, so the second email address on the list receives the message twice, the third person three times and so on.

Any help would be greatly appreciated, below is the code

<%
Dim SQL, rsNewsletter
SQL = "SELECT * FROM tblnewsletters "
SQL = SQL & "WHERE idissue = " & idissue
set rsNewsletter = conn.execute(SQL)
if not rsNewsLetter.eof then
vDescription = rsNewsletter("chrdescription")
vNewstitle = rsNewsletter("chrtitle")
vNewsfile = rsNewsletter("chrfile")
End if
rsNewsLetter.close

Dim rsSubscribe
SQL = "SELECT * FROM tblezine"
SQL = SQL & " ORDER BY chremail"
Set rsSubscribe = conn.execute(SQL)

Do Until rsSubscribe.EOF

'Send Newsletter
Dim MyCDONTSMail2
Dim HTML
Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
HTML = HTML & "<html>"
HTML = HTML & "<body>"
HTML = HTML & "<link href=""http://westwood.users19.donhost.co.uk/westwood.css"" rel=""stylesheet"" type=""text/css""> "
HTML = HTML & "<table width=""750"" border=""0"" cellpadding=""5"" cellspacing=""0"" class=""mainbar"">"
HTML = HTML & "<tr>"
HTML = HTML & "<td><p class=""titles""><img src=""http://westwood.users19.donhost.co.uk/img/logo_4.gif"" align=""right"">Westwood Club: " & vNewsTitle & "</p>"
IF vNewsFile <> "" THEN
HTML = HTML & "<p><a href=""http://westwood.users19.donhost.co.uk/pdf/" & vNewsfile & " "">Click here to be taken to the newsletter</a> (Requires Acrobat Reader)</p>"
END IF
HTML = HTML & "<p>" & replace(vDescription,vbcrlf,"<BR>") & "</p>"
HTML = HTML & "<p><a href=""http://westwood.users19.donhost.co.uk/index.asp"">Click here to be taken to our website</a></p>"
HTML = HTML & "<p><a href=""http://westwood.users19.donhost.co.uk/unsubscribe.asp?idezine=" & rsSubscribe("idezine") & "&chremail=" & rsSubscribe("chremail") & """>Click here to unsubscribe to this newsletter</a></p>"
HTML = HTML & "West Wood Club | Clontarf Rd | Dublin 3 | <br>"
HTML = HTML & "Tel: +353 1 222 2222 | Fax: +353 1 222 2222<br> &copy; West Wood Fitness"
HTML = HTML & "Club 2003. All Rights Reserved.</td>"
HTML = HTML & "</tr>"
HTML = HTML & "</table>"
HTML = HTML & "</body>"
HTML = HTML & "</html>"

MyCDONTSMail2.From= "info@westwood.ie"
MyCDONTSMail2.To= rsSubscribe("chremail")
MyCDONTSMail2.Subject="Westwood Club: " & vNewstitle
MyCDONTSMail2.BodyFormat=0
MyCDONTSMail2.MailFormat=0
MyCDONTSMail2.Body=HTML
MyCDONTSMail2.Send
set MyCDONTSMail2=nothing


rsSubscribe.MoveNext
Loop
rsSubscribe.Close
%>

rdoekes
09-30-2003, 02:09 PM
HTML = HTML & "<html>"
should be:
HTML = "<html>"

the variable HTML needs to be initialized at every loop

-Rogier Doekes

fvillena
10-01-2003, 04:16 AM
Many thanks, working fine now.

jmlynn
11-12-2003, 08:13 PM
I tried on my WinNT and it works!

Can someone tell me how CDONTS get hold of the SMTP server name, authentication ID and password to use to send the e-mail out?

JML

rdoekes
11-13-2003, 03:36 AM
CDONTS works with the local SMTP server, which you can install with IIS.

jmlynn
11-13-2003, 11:03 AM
Yes, I read from other postings regarding to the default SMTP under IIS prior to my last posting.

I selected SMTP server when I installed IIS way back at least 1 year ago. I had never configure the default SMTP server so the SMTP Host field was left empty. Also, my server was connected to cable ISP who require authentication before I can send mail out to its mail server.

That is why I was bothered that where the CNONTS got the host name as well as to the authentication info to send the mail.

All e-mail are sent out from different PC connected to the Net via multiple hubs so my NT server did not send e-mail out. Jst wonder if CDONTS may be able to steal that kind of info from the NT Server's OutlookExpress cliient that I used once long time ago that I had abandon the idea of running any non-essential app on my NT server.

Thanks for your previous reply.

Jeff