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

Email Dropdown list

Status
Not open for further replies.

lamore

Technical User
Nov 19, 2000
11
0
0
US
Hi all, I have a form with a dropdown for category, and what I want to do is be able to email different people based on who is chosen in the dropdown category. ie if safety was chosen then the email would go to the safety department, if environment was chosen then email would go to environment engineer.
Thanks,
Lenny
 
Hey Lenny,

Yeah, in fact I have one myself depending on user level.

First page I have items like subject, message, importance, and a dropdown containing the user levels.

that submits to the second page, with this code.

<%
Dim rsStatus__MMColParam
rsStatus__MMColParam = &quot;MOD&quot;
if (Request(&quot;MM_EmptyValue&quot;) <> &quot;&quot;) then rsStatus__MMColParam = Request(&quot;MM_EmptyValue&quot;)
%>
<%
set rsStatus = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rsStatus.ActiveConnection = MM_Your_STRING
rsStatus.Source = &quot;SELECT callsign, pilot_status FROM tblPilots WHERE pilot_level = '&quot; + Replace(rsStatus__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;' ORDER BY callsign ASC&quot;
rsStatus.CursorType = 0
rsStatus.CursorLocation = 2
rsStatus.LockType = 3
rsStatus.Open()
rsStatus_numRows = 0
%>
<%
Dim rs__MMColParam
rs__MMColParam = &quot;1&quot;
if (Request.Form(&quot;fldRecipients&quot;) <> &quot;&quot;) then rs__MMColParam = Request.Form(&quot;fldRecipients&quot;)
%>
<%
' Declaring variables
Dim rs, mail, subject, message, data_source, sql_select, strImportance, no

no = 0
subject = Request.Form(&quot;fldsubject&quot;)
message = Request.Form(&quot;fldmessage&quot;)
strImportance = Request.Form(&quot;fldImportance&quot;)
' Adding a link to all messages by which users can delete their
' emails if they would want later

set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.ActiveConnection = MM_Your_STRING
rs.Source = &quot;SELECT email FROM tblPilots WHERE pilot_level = '&quot; + Replace(rs__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;' ORDER BY callsign ASC&quot;
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 CDO

While Not rs.EOF
Set MyMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
MyMail.From = &quot;Webmaster@YourDomain.com&quot;
MyMail.Subject = subject
MyMail.to = rs(&quot;email&quot;)
MyMail.CC = &quot;webmaster@YourDomain.com&quot;
MyMail.MailFormat = 0
MyMail.BodyFormat = 0
MyMail.Body = message
MyMail.importance = strImportance
MyMail.Send
Set MyMail = nothing

no = no + 1
rs.MoveNext
Wend

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


' Had you pressed the button mistakenly with text area empty, then
' redirect back to the HTML Form
Else
Response.Redirect &quot;sendemail.asp&quot;
End If
%> &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
I was reading the code but I don't see how that would do what I want, it looks like it just emails everyone on the list. I want it to email just the chosen category.
Thanks,
Lenny
 
Yes exactly,

If you look at the first recordset
<color blue>
&quot;SELECT callsign, pilot_status FROM tblPilots WHERE pilot_level = '&quot; + Replace(rsStatus__MMColParam, &quot;'&quot;, &quot;''&quot;) + &quot;' ORDER BY callsign ASC&quot;
</color>

Will pull only those (in my case) of what User level or Pilot_level is selected on the previous page. &quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Here is a JMail version as well

faq770-1708

&quot;Damn the torpedoes, full speed ahead!&quot;

-Adm. James Farragut

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top