Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 367169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:42:08+00:00 2026-05-12T13:42:08+00:00

I have an Classic ASP page that lets users search for properties and a

  • 0

I have an Classic ASP page that lets users search for properties and a results page that then emails the property agents who have matching properties to let them know that there are tenants interested in their properties.

Some agents may have more than 1 property, in which case the agent only needs to receive 1 email rather than an email for each property they have. Currently my code is doing the latter and I need it to only send 1 email to each agent.

In the code below I have 2 recordsets; rspropertyresults displays all matching properties and then I have rsemailagents which is used to gather the agent’s email address and send them an email.

I was wondering if anyone might be able to see how I can amend the sql query for rsemailagents to send out 1 email per agent?

<%
[...]
rsemailagents.Source = "SELECT *"
rsemailagents.Source = rsemailagents.Source& "FROM    ("
rsemailagents.Source = rsemailagents.Source& "        SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "        FROM    ("
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentStreet = '" & Replace(rsemailagents__varReqStreet, "'", "''") & "'"
rsemailagents.Source = rsemailagents.Source& "                UNION ALL"
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentTown = '" & Replace(rsemailagents__varReqTown, "'", "''") & "'"
rsemailagents.Source = rsemailagents.Source& "                UNION ALL"
rsemailagents.Source = rsemailagents.Source& "                SELECT  ContentID"
rsemailagents.Source = rsemailagents.Source& "                FROM    VWTenantPropertiesResults"
rsemailagents.Source = rsemailagents.Source& "                WHERE   ContentTrimmedPostCode LIKE '" & Replace(varPostcode, "'", "''") & "%'"
rsemailagents.Source = rsemailagents.Source& "                ) qi"
rsemailagents.Source = rsemailagents.Source& "        GROUP BY"
rsemailagents.Source = rsemailagents.Source& "                ContentID"
rsemailagents.Source = rsemailagents.Source& "        HAVING  COUNT(*) >= 2"
rsemailagents.Source = rsemailagents.Source& "        ) q "
rsemailagents.Source = rsemailagents.Source& "JOIN    VWTenantPropertiesResults r "
rsemailagents.Source = rsemailagents.Source& "ON      r.ContentID = q.ContentID "
rsemailagents.Source = rsemailagents.Source& "WHERE   ContentBedrooms BETWEEN " & Replace(rsemailagents__varBedroomsNoMin, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     " & Replace(rsemailagents__varBedroomsNoMax, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     ContentPrice BETWEEN " & Replace(rsemailagents__varPriceMin, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "AND     " & Replace(rsemailagents__varPriceMax, "'", "''") & " " & varSQL & " "
rsemailagents.Source = rsemailagents.Source& "ORDER BY"
rsemailagents.Source = rsemailagents.Source& "        ContentPrice " & Replace(rsemailagents__varSortWay, "'", "''") & " "
rsemailagents.Source = rsemailagents.Source& "GROUP BY CustomerEmail"

[...]
%>

In my email code I have set the objMail.To as follows;

objMail.To = (rsemailagents.Fields.Item("CustomerEmail").Value)

This is the VWTenantPropertiesResults code;

SELECT     dbo.VWResidentialLettings.ContentID, dbo.VWResidentialLettings.ContentTitle, dbo.VWResidentialLettings.ContentBriefText, 
                      dbo.VWResidentialLettings.ContentDetails, dbo.VWResidentialLettings.ContentHouseNo, dbo.VWResidentialLettings.ContentStreet, 
                      dbo.VWResidentialLettings.ContentStreet2, dbo.VWResidentialLettings.ContentTown, dbo.VWResidentialLettings.ContentArea, 
                      dbo.VWResidentialLettings.ContentCounty, dbo.VWResidentialLettings.ContentPostCode, dbo.VWResidentialLettings.ContentReference, 
                      dbo.VWResidentialLettings.ContentPrice, dbo.VWResidentialLettings.ContentPricePeriod, dbo.VWResidentialLettings.ContentPriceText, 
                      dbo.VWResidentialLettings.ContentPropertyType, dbo.VWResidentialLettings.PropertyTypeTitle, dbo.VWResidentialLettings.ContentPropertyListType, 
                      dbo.VWResidentialLettings.PropertyListTypeTitle, dbo.VWResidentialLettings.PricePeriodTitle, dbo.VWResidentialLettings.BedRoomNoTitle, 
                      dbo.VWResidentialLettings.ContentBedRooms, dbo.VWResidentialLettings.ContentFurnishing, dbo.VWResidentialLettings.FurnishTypeTitle, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerID, dbo.VWPropertyAgentsActiveSubscriptions.CustomerName, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerBusiness, dbo.VWPropertyAgentsActiveSubscriptions.CustomerAddress1, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerAddress2, dbo.VWPropertyAgentsActiveSubscriptions.CustomerCity, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerArea, dbo.VWPropertyAgentsActiveSubscriptions.CustomerRegion, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerPostalCode, dbo.VWPropertyAgentsActiveSubscriptions.CustomerPhone, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerFax, dbo.VWPropertyAgentsActiveSubscriptions.CustomerURL, 
                      dbo.VWPropertyAgentsActiveSubscriptions.CustomerEmail, dbo.VWResidentialLettings.CountyTitle, dbo.VWResidentialLettings.ContentCreated, 
                      dbo.VWResidentialLettings.ContentUpdated, dbo.VWResidentialLettings.ContentStatus, dbo.VWPropertyImagesList.DocumentFile, 
                      dbo.VWPropertyImagesList.DocumentTitle, dbo.VWResidentialLettings.ContentTrimmedPostCode, dbo.VWPropertyImagesList.ContentStatusTitle
FROM         dbo.VWResidentialLettings INNER JOIN
                      dbo.VWPropertyAgentsActiveSubscriptions ON 
                      dbo.VWResidentialLettings.ContentParentID = dbo.VWPropertyAgentsActiveSubscriptions.CustomerID LEFT OUTER JOIN
                      dbo.VWPropertyImagesList ON dbo.VWResidentialLettings.ContentID = dbo.VWPropertyImagesList.ContentID
WHERE     (dbo.VWResidentialLettings.ContentStatus = 2)

When I run this query in the database, it is just returning a CustomerEmail column and nothing else;

SELECT DISTINCT CustomerEmail
FROM    (
    SELECT  ContentID
    FROM    (
                SELECT  ContentID
                FROM    VWTenantPropertiesResults
                WHERE   ContentStreet = 'Hull'
                UNION ALL
                SELECT  ContentID
                FROM    VWTenantPropertiesResults
                WHERE   ContentTown = ''
                UNION ALL
                SELECT  ContentID
                FROM    VWTenantPropertiesResults
                WHERE   ContentTrimmedPostCode LIKE 'HU7'
                ) qi
        GROUP BY
                ContentID
        HAVING  COUNT(*) >= 2
        ) q
JOIN    VWTenantPropertiesResults r
ON      r.ContentID = q.ContentID
WHERE   ContentBedrooms BETWEEN 1 AND 10 AND ContentPrice BETWEEN 1 AND 10
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:42:09+00:00Added an answer on May 12, 2026 at 1:42 pm

    Put your query into the IN clause of this query

    SELECT  email
    FROM    agents
    WHERE   id IN
            (
            SELECT  agentID
            FROM    …
            )
    

    This will select each agent only once.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Classic ASP page that lets users search for properties and a
I have a Classic ASP page that contains the following code to attempt a
We have a classic ASP page that is instantiating a .Net object through a
I have a classic ASP page that submits back to itself. Strangely, the values
I have a classic ASP page that requires two values from a form. These
I've got a fairly complex classic asp page that for some users doesn't render
We have a classic ASP application that simply works and we have been loathe
I have a large classic ASP app that I have to maintain, and I
I have been developing in asp.net since its existence (also classic asp before that)
I'm converting a classic ASP page to ASP.NET MVC 2. I have a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.