Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - send email to selected users in DB
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

send email to selected users in DB

 Post Reply Post Reply
Author
dizzyfunk View Drop Down
Newbie
Newbie


Joined: 12 September 2003
Location: United Kingdom
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote dizzyfunk Quote  Post ReplyReply Direct Link To This Post Topic: send email to selected users in DB
    Posted: 14 September 2003 at 2:52pm

i want to be able to search a database of users on a variety of criteria, then send an email (using cdonts or jmail) to only the users that the search brought back.

eg... i will search the DB for all surname of 'smith' then send them an email. next i will search for surname 'johnson' AND city of 'london' and then send them an email...

i want to see the search results displayed on a page first so i can look at it.. that i can do... i then want a button on the results page that will send the email to all users on that page...

you see, the search criteria can vary each time.

hope some one can help me from pulling my hair out...

many thanks.. an asp newbie ;)

 

 

Back to Top
mapnapkin View Drop Down
Newbie
Newbie


Joined: 28 January 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote mapnapkin Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 4:45pm

i use access db and aspEmail but you can rearrange this for your use

---------------------------------------
<%
Dim Mail, customer

set conn=Server.CreateObject("ADODB.Connection")
conn.provider="Microsoft.Jet.OLEDB.4.0"
conn.open(server.mappath("database.mdb"))
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT customers.custemail FROM customers, orders WHERE orders.cust_id=customers.cust_id AND orders.lottostate='" & Request.Form("lottostate") & "' AND orders.order_status='active' AND orders.expire_date>= date() ", conn
%>
<%
do until rs.EOF
%>
<%
customer=rs("custemail")
%>
<%
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "smtp.domain.com" ' Specify a valid SMTP server
Mail.From = "email@website.com" ' Specify sender's address
Mail.FromName = "Your From Name" ' Specify sender's name
Mail.AddAddress customer
Mail.AddReplyTo "email@website.com"
Mail.Subject = "..Your Subject.."
Mail.isHTML = True
Mail.Body = request.form("body")

On Error Resume Next
Mail.Send

IF Err <> 0 THEN
Response.Write "Ah man.. you messed it up!! <font color=""#ff0000"">""" & Err.Description & """</font>"
END IF
%>

<%
rs.MoveNext
loop
%>

<%
rs.close
conn.close
Set Mail = Nothing
Set rs = Nothing
set conn = Nothing
%>

<%
Response.Write "Your message has been successfully sent.<br /><br /><strong><font color=""#FF0000""><a href=""page.asp"">BACK</a></font></strong& gt;</font>"
%>
----------------------------------------------------

hope that helps

Back to Top
dizzyfunk View Drop Down
Newbie
Newbie


Joined: 12 September 2003
Location: United Kingdom
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote dizzyfunk Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 5:04pm

no.. i can do this....

maybe it isn't clear!

this is ok when i know what the search criteria is.. but this will differ each time.. imagine an advanced search form.. you only use a couple of the search fields, but one search will use different fields from the last.. therefore i won't know what SQL string to write out eachtime to send the email?

(please read my original post clearly - I DO NOT NEED TO KNOW HOW TO SEND EMAIL USING ASP - that i can do)

Back to Top
mapnapkin View Drop Down
Newbie
Newbie


Joined: 28 January 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote mapnapkin Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 5:17pm

ok cap lock

what is your submit form code



Edited by mapnapkin
Back to Top
dizzyfunk View Drop Down
Newbie
Newbie


Joined: 12 September 2003
Location: United Kingdom
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote dizzyfunk Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 5:26pm

SORRY!

no.. today i may wish to search the db for people in london then email them... (1 criteria)

2moro i'll need all the 'smiths' from manchester and email them.. (2 criteria)

then i might need to be more specific and search for people from london, with birthday in september, and surname of jones (3 criteria)

so ya see it's always different!

if it was always the same one it'd be easy, but it's not

Back to Top
mapnapkin View Drop Down
Newbie
Newbie


Joined: 28 January 2003
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote mapnapkin Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 5:41pm

you can put an "if then" statment in your SELECT string.... to check if a text field is empty if its not then then response.write it into your SELECT string
-----------------------------

sqlselect ="SELECT * FROM emails WHERE " "

<% if Requst.form("surname")="" then  %><%else%>
sqlselect = sqlselect & " surname=' " & Request.Form("surname") &" ' "
<%end if%>

<% if Requst.form("city")="" then  %><%else%>
sqlselect = sqlselect & " AND city=' " & Request.Form("city") &" ' "
<%end if%>

---------------------------
something like that



Edited by mapnapkin
Back to Top
dizzyfunk View Drop Down
Newbie
Newbie


Joined: 12 September 2003
Location: United Kingdom
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote dizzyfunk Quote  Post ReplyReply Direct Link To This Post Posted: 14 September 2003 at 5:49pm

yup.. thanks.. i can see that workin!

thanks for your time.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.