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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing a group from database w/Jmail

Dreamweaver & Flash

Emailing a group from database w/Jmail

by  schase  Posted    (Edited  )
Ok, now I found similiar, This one in fact came from Stardeveloper.com I had to modify to work - the others I found were close but it wouldnt let me email a specific "group" within my database. This does. The manner I came about this - Created a form on a page called sendemail.asp.

Have the following fields.
fldRecipients - the Groups name
fldSubject - self explanitory
fldMessage - self Explanitory
fldFrom - This I brought the value in as the logged-in session variable.

This page submits to sendemail2.asp This page displays everything you typed - and sends the email. When I created the recordset - I filtered by in my case Pilot_Level, with form variable of fldRecipients. This brought out only that group you wanted.

now sendemail.asp is a simple form entry page. Onto SendEmail2.asp all this goes above the <head> tags of course. and naturally you'll have to modify to fit your fields with your group stuff, smtp server, you get the point.
[color blue]
<%
Dim rs__MMColParam
rs__MMColParam = "1"
if (Request.Form("fldRecipients") <> "") then rs__MMColParam = Request.Form("fldRecipients")
%>
<%
' Declaring variables
Dim rs, mail, subject, message, data_source, sql_select, strImportance, no

no = 0
subject = Request.Form("fldsubject")
message = Request.Form("fldmessage")
strImportance = Request.Form("fldImportance")

set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = MM_changetoyour_STRING
rs.Source = "SELECT email FROM tblPilots WHERE pilot_level = '" + Replace(rs__MMColParam, "'", "'") + "' ORDER BY callsign ASC"
rs.CursorType = 0
rs.CursorLocation = 2
rs.LockType = 3
rs.Open()
rs_numRows = 0

' Check to see if you have not pressed the 'send' button mistakenly
If Len(message) Then

' If you have written some message then lets send it
' You can use ASP Email component of your choice, here I will
' stick with JMAIL

While Not rs.EOF
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "smtp.yourdomain.com"
JMail.ContentType = "text/html"
Jmail.Sender = "webmaster@yourdomain.com"
Jmail.AddRecipient rs("email")
Jmail.Subject = subject
Jmail.Body = message
JMail.Priority = strImportance
Jmail.Execute
Set Jmail = Nothing
no = no + 1
rs.MoveNext
Wend

' When messages have been sent to all the users, exit
Response.Write "Emails sent to " & no & " users."


' Had you pressed the button mistakenly with text area empty, then
' redirect back to the HTML Form
Else
Response.Redirect "sendemail.asp"
End If
%>
[/color]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top