 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 4th, 2004, 11:53 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay I set up a test Table with 10 email addy's in it. I will try and send it to 5 at a time.
I am not sure how to do this exactly
While not RS.EOF
Send mail one by one.
And store the mailId or KeyFieldValue in an array.
WEND
I am not good with array's at all :(
-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
|
|

June 4th, 2004, 02:07 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can this be done?
Couldn't I just loop through the entire record sending one email to each record and then just close the record set and have .eof = true and move on to the next page.
Or would this be way too much work for the server?
-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
|
|

June 4th, 2004, 03:25 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Here's what I would do:
1. SELECT TOP 50 FROM Bla bla WHERE mailsent=0
(assuming your database supports Top)
2. Loop through the recordset and send out your e-mail. Inside the loop, keep track of the IDs of the customer in a comma separated string:
If Len(CustomerIDs) > 0 Then
CustomerIDs = CustomerIDs & ", "
End If
CustomerIDs = CustomerIDs & MyRecordset("CustomerID")
3. After the loop, update your database by using the CustomerIDs string. At the end of the loop, that string will hold something like this:
1, 3, 7, 12, 45
Use the statement that Vijay showed you earlier:
"UPDATE YourTable SET Mailsent=1 WHERE CustomerID IN (" & CustomerIDs & ")"
This will set the MailSent flag to 1 for all the customers you just e-mailed.
4. Repeat step 1 through 3 while the reocrdset is not EOF (that is, there are still messages left to send / MailSent = 0)
I introduced the Date column because I wasn't sure how and when you send out your e-mail. Suppose some automatic routine sets all the MailSent flags to 0 again, in the middle of your code loop. That would cause the mail to be sent again.
However, the solution Vijay proposed, where you loop your code until the recordset is EOF and then immediately set all the MailSent flags back to 0 seems to make a lot of sense. This way, you only need to run the page once, to get it all done.
Is scheduling a script instead of using an ASP page an option for you?
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

June 4th, 2004, 05:20 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Have you considered using a list server. The server ought to be able to queue up whatever it can handle while crack listing the message to individual recipients. That way you only have to send to one address.
|
|

June 5th, 2004, 03:50 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Dave,
That option is ruled out in Morpheus's case, as he is sending personalised content for every recipient. Please read my 3rd previous post to this. Also read Morpheus's original post, where the code would show that he uses personalised content for every recipient. So I dont think that can help him.
Cheers!
_________________________
-Vijay G
 Strive for Perfection 
|
|

June 7th, 2004, 07:15 AM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry I didn't get back, I was away all weekend. Thanks Guys for your help, To Imar, I don't think scheduling a script is an option for us because I don't know when it will go out each day, I guess it could be set to send the newsletter at 5pm when everyone leaves for the day, but I am not sure if they would want that and also I have never done that before :(
I am going to work on the 50 at a time and see if that does the trick. I will let you know how it goes.
Thanks
-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
|
|

June 9th, 2004, 01:01 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the help guys but I am getting stuck on this one line
NewsletterId = NewsletterId & RS("NewsletterId")
It says Exception occurred for this line and I am not sure why, is this the proper syntax?
Thanks
-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
|
|

June 9th, 2004, 01:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you post some more code? I can't see anything wrong with this single line. Posting the exact error message may help as well.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

June 9th, 2004, 01:18 PM
|
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Okay Imar I was using your example that you and vijay helped me with.
SQLStr="SELECT top 50 * FROM ORNewsletterTest"
Set RS=Server.CreateObject("ADODB.Recordset")
RS.Open SQLStr,Application("DBConn"),1,2,&H0001
while not rs.eof
Body of the Email
If len(NewsletterId) > 0 Then
NewsletterId = NewsletterId & ", "
end if
NewsletterId = NewsletterId & RS("NewsletterId")
wend
update "ORNewsletterTest set Mailsent=1 where NewsletterId In (" & NewsletterId & ")"
Maybe I don't have this in the right order, but I left off the code to set all the mailsent back to 0 because I want to make sure that it is working, but it was getting stuck on the line above
-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
|
|

June 9th, 2004, 01:24 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What error do you get?
Imar
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Newsletter Mechanism |
vivek_inos |
ASP.NET 1.0 and 1.1 Professional |
1 |
September 22nd, 2007 07:38 AM |
| Where is the newsletter option |
luisjeronimo |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 |
3 |
July 20th, 2007 03:16 PM |
| newsletter |
vantoko |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 |
2 |
February 28th, 2007 03:28 AM |
| Newsletter |
sydneyausguy |
BOOK: Professional DotNetNuke ASP.NET Portals ISBN: 0-7645-9563-6 |
1 |
August 19th, 2005 05:23 PM |
| help with newsletter question |
AStuntz |
Beginning PHP |
1 |
May 13th, 2004 06:54 PM |
|
 |