Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email alerts to subscribers

Status
Not open for further replies.

3dColor

Programmer
Jan 10, 2006
240
US
I am creating an email alert system so when a new ad is posted within a certain metro area, emails will be sent out to those that have subscribed to that metro area's alert.

Users can subscribe to multiple metro areas. I want to send one email to each subscriber which contains all the alerts for multiple metro areas.

I can write a query just fine for returning all the ads that were posted the day before (emails sent out 3AM in the morning), see below:

Code:
"GetNewAds" Query
SELECT 	Parameter.BeginDate, Parameter.listingFK, Parameter.status, Listing.listingId, Listing.address, Listing.metroFk
FROM Listing INNER JOIN Parameter ON Listing.ListingId = Parameter.listingFk
WHERE BeginDate = #yesterday#

And I can write another query that returns all the alerts based off the first query's metro area(s):

Code:
"GetAlert" Query
SELECT 	Alerts.acctFk, Alerts.metroFk,	Account.acctId, Account.email, Account.nameFull
FROM 	Alerts INNER JOIN Account ON Alerts.acctFk = Account.acctId
WHERE 	Alerts.metroFk = '#GetNewAds.metroFk#'

I am having a hard time trying to figure out how to loop through the emails and providing the address of each new ad:

Code:
-- loop through the "GetAlert" query --

 send email to address from GetAlert query

   -- 2nd loop --
   within email include all new ads from 1st metro area
   -- end 2nd loop --

   -- 3rd loop --
   within email include all new ads from 2st metro area
   -- end 3rd loop --

   etc.

-- end loop --

My guess is to JOIN the two queries some how, but I am at a loss on how to do that for this type of email output - any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top