Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old June 4th, 2004, 11:53 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #12 (permalink)  
Old June 4th, 2004, 02:07 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #13 (permalink)  
Old June 4th, 2004, 03:25 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.
Reply With Quote
  #14 (permalink)  
Old June 4th, 2004, 05:20 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

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.

Reply With Quote
  #15 (permalink)  
Old June 5th, 2004, 03:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
  #16 (permalink)  
Old June 7th, 2004, 07:15 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #17 (permalink)  
Old June 9th, 2004, 01:01 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #18 (permalink)  
Old June 9th, 2004, 01:13 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

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.
Reply With Quote
  #19 (permalink)  
Old June 9th, 2004, 01:18 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #20 (permalink)  
Old June 9th, 2004, 01:24 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

What error do you get?

Imar
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.