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

Maybe a loop, Maybe not a loop. Need Help, please 2

Status
Not open for further replies.

jmiller79

Programmer
Jul 13, 2004
48
US
I do not know if this should go into the SQL forum instead but I will try this one first. I have a contact database in MS SQL. IT records the following data, Name, Email, Address, City, and State. There are about 50 records in this one table. There could be more but not a lot more; maybe another 20. On another page I have a quote form. After the user fills out the quote form I want to be data to automatically email the data to people in the contact database. But here is where I am very confused, sometimes the quote data is going to be useless for some of the contacts, So I do not want them to get it, so I want the user who is filling out the quote form to be able to have check boxes just atop of the Submit button and the user can check off the boxes he/she wants to send the quote to. The checkboxes will be dynamic, It will be populated by the contact database (which I have no problem doing). Does anyone have any ideas or maybe a different way of doing this, anything would be much appreciated.
 
try something like this

just keep the same name for all the checkbox and have the value to the id

ex.
<input type="checkbox" name="emailto" value="1"><br>
<input type="checkbox" name="emailto" value="2"><br>
<input type="checkbox" name="emailto" value="3">

the on the page that does the send create a select statement like this

strChecked = "" + Request.Form(emailto) + ""

sql="SELECT * FROM tblname WHERE Id IN (" & strChecked & ") "

then just loop through to send the emails
 
Would the check boxes only have on name because it is populated by the contact table? When I set it up I only put one check box on the page and name it email and then I populate the checkboxes by the Contact Table.

This is the code(ASPMAIL) I use for AfterExecuteInsert

Dim Mailer
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = "joe@logistics.com"
Mailer.FromName = "Quote Dept."
Mailer.AddRecipient Request.Form("Email"), Request.Form("Email")
Mailer.RemoteHost = "mail.corsair.com"
Mailer.Subject = "Quote Request from " & Request.Form("Filed") & VbCrLf & ", Thank You"
Mailer.ContentType = "text/html"
Mailer.Priority = 1
Mailer.BodyText ="Test"
Mailer.SendMail
set Mailer = Nothing
 
i would put this mailer in a function then just loop it you, quick example

sub sendmail(semail,ssubject)
Dim Mailer
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = "joe@logistics.com"
Mailer.FromName = "Quote Dept."
Mailer.AddRecipient semail
Mailer.RemoteHost = "mail.corsair.com"
Mailer.Subject = "Quote Request from " & ssubject & VbCrLf & ", Thank You"
Mailer.ContentType = "text/html"
Mailer.Priority = 1
Mailer.BodyText ="Test"
Mailer.SendMail
set Mailer = Nothing
end sub

this is a different option - does not require the select statement

just make the checkbox values equal to the emailaddress

then just loop throught the checkboxes

arr=split(Request.Form("Email"),",")

for i= lbound(arr) to ubound(arr)
call sendmail(arr(i),request.form("filed"))
next
 
Where would I put the following code, And Thanks for all your help.

""
then just loop throught the checkboxes

arr=split(Request.Form("Email"),",")

for i= lbound(arr) to ubound(arr)
call sendmail(arr(i),request.form("filed"))
next
 
you would place this on the page the form submits to

but make sure you have the subroutine on this page so you page could look like this

[pagesubmittedto.asp]

Code:
<%
sub sendmail(semail,ssubject)
Dim Mailer
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = "joe@logistics.com"
Mailer.FromName = "Quote Dept."
Mailer.AddRecipient semail
Mailer.RemoteHost = "mail.corsair.com"
Mailer.Subject = "Quote Request from " & ssubject & VbCrLf & ", Thank You"
Mailer.ContentType = "text/html"
Mailer.Priority = 1
Mailer.BodyText ="Test"
Mailer.SendMail
set Mailer = Nothing
end sub


arr=split(Request.Form("Email"),",")

for i= lbound(arr) to ubound(arr)
call sendmail(arr(i),request.form("filed"))
strsento=strsento & arr(i)&"<br>"
next
response.write "email sent to"&"<br>"&strsento
%>
 
Thanks I inserted the code and got this error

Microsoft VBScript compilation error '800a03ea'

Syntax error

/FreightCenter/RFQ/New_events.asp, line 12

sub sendmail(semail,ssubject)
^
 
what if you changed sub to function?
and end function
 
This is my whole page of events. it is called News_Events.asp. My Form is called RFQTest.
Code:
<%

Sub BindEvents()
    Set RFQTest.DataSource.CCSEvents("AfterExecuteInsert") = GetRef("RFQTest_DataSource_AfterExecuteInsert")
End Sub


Function RFQTest_DataSource_AfterExecuteInsert() 


sub sendmail(semail,ssubject)
Dim Mailer
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = "joe@logistics.com"
Mailer.FromName = "Quote Dept."
Mailer.AddRecipient semail
Mailer.RemoteHost = "mail.corsair.com"
Mailer.Subject = "Quote Request from " & ssubject & VbCrLf & ", Thank You"
Mailer.ContentType = "text/html"
Mailer.Priority = 1
Mailer.BodyText ="Test"
Mailer.SendMail
set Mailer = Nothing
end sub


arr=split(Request.Form("Email"),",")

for i= lbound(arr) to ubound(arr)
call sendmail(arr(i),request.form("filed"))
strsento=strsento & arr(i)&"<br>"
next
response.write "email sent to"&"<br>"&strsento


End Function 


%>
 
is this .net or classic asp

I don't think you place a sub within a function?

 
what are you trying to do with the bindEvents subroutine?

did you try just using this in the News_events.asp

Code:
<%
sub sendemail(semail,ssubject)
Dim Mailer
Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.FromAddress = "joe@logistics.com"
Mailer.FromName = "Quote Dept."
Mailer.AddRecipient semail
Mailer.RemoteHost = "mail.corsair.com"
Mailer.Subject = "Quote Request from " & ssubject & VbCrLf & ", Thank You"
Mailer.ContentType = "text/html"
Mailer.Priority = 1
Mailer.BodyText ="Test"
Mailer.SendMail
set Mailer = Nothing
end sub


arr=split(Request.Form("Email"),",")

for i= lbound(arr) to ubound(arr)
call sendemail(arr(i),request.form("filed"))
strsento=strsento & arr(i)&"<br>"
next
response.write "email sent to"&"<br>"&strsento
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top