By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

System generated email...

P: n/a
I have an asp page that collects data on referrals. The user inputs the
information and selects the rep to receive the referral. My data is being
saved to a backend database (SQL) and the user is receiving a confirmation
page after hitting the Submit button. Now, what I need is a way to have an
email sent to the rep that is selected in the drop down list on the asp form.
I have a SQL table containing the reps and corresponding email addresses.

Is it even possible to achieve what I am trying to do? I am trying to avoid
sending a blanket email to a single address and having someone filter them
from there.

HELP...
Jun 8 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Ken D." wrote ...
Is it even possible to achieve what I am trying to do? I am trying to
avoid
sending a blanket email to a single address and having someone filter them
from there.


Hi Ken,

If I'm following you correctly then yes...
In your code that handles the form being submitted...

strRepID = request.form("repid") ' replace this with the name of your
drop down list - I'm assuming it contains an ID for the rep?

' run a query against your database to return the email address - a
stored procedure to return it based on the rep id might be nice
' strEmailAddress = RS("RepsEmailAddress")

' send the email using the above string in the TO property
' (see this article for an example on sending CDO emails
http://www.aspfaq.com/show.asp?id=2339)

Hope this is of some help...you could tart it up a bit by doing some checks
to see if you returned a reps details or not and displaying a suitable
message if not, in addition your stored procedure could also get the reps
name and you could then on your confirmation page say "An email has been
sent to Mr A Rep" etc etc..

Regards

Rob
Jun 9 '06 #2

P: n/a
Rob,

Thanks for the reply. Not being a programmer, sometimes I am a bit
challenged. Let me ask you this. I have an asp page that I built in
Frontpage 2002 that upon submit, sends data to a SQL database and provides a
confirmation to the user. I want to initiate the email to the rep selected
in a combo box on the asp form at the same time the submit button is
selected. I have a stored procedure that returns the last entered rep (and
it works great). My question is, where do I insert your code in order to get
it to fire at the submit event. I understand the script goes on my asp page
but where does the strRepID and strEmailAddress go and how does it get called.

Sorry to sound so confusing with this. Any help would be appreciated.

Ken

"Rob Meade" wrote:
"Ken D." wrote ...
Is it even possible to achieve what I am trying to do? I am trying to
avoid
sending a blanket email to a single address and having someone filter them
from there.


Hi Ken,

If I'm following you correctly then yes...
In your code that handles the form being submitted...

strRepID = request.form("repid") ' replace this with the name of your
drop down list - I'm assuming it contains an ID for the rep?

' run a query against your database to return the email address - a
stored procedure to return it based on the rep id might be nice
' strEmailAddress = RS("RepsEmailAddress")

' send the email using the above string in the TO property
' (see this article for an example on sending CDO emails
http://www.aspfaq.com/show.asp?id=2339)

Hope this is of some help...you could tart it up a bit by doing some checks
to see if you returned a reps details or not and displaying a suitable
message if not, in addition your stored procedure could also get the reps
name and you could then on your confirmation page say "An email has been
sent to Mr A Rep" etc etc..

Regards

Rob

Jun 9 '06 #3

P: n/a
If you think about the logic flow of your process, it should be fairly
obvious. You need the rep's email address before you can send an email
to him/her, right? So the email generation code has to go at some
point after the code that successfully retrieves this information from
your database.

You have three actions to perform after you have retrieved the rep
info:
1. Send an email
2. Write to the db
3. Display a confirmation page.

I can't see that it matters in which order you code these actions.
None of them are dependent on the other, but all are dependent on
successful validation of the information submitted in the form.

--
Mike Brind

Ken D. wrote:
Rob,

Thanks for the reply. Not being a programmer, sometimes I am a bit
challenged. Let me ask you this. I have an asp page that I built in
Frontpage 2002 that upon submit, sends data to a SQL database and provides a
confirmation to the user. I want to initiate the email to the rep selected
in a combo box on the asp form at the same time the submit button is
selected. I have a stored procedure that returns the last entered rep (and
it works great). My question is, where do I insert your code in order to get
it to fire at the submit event. I understand the script goes on my asp page
but where does the strRepID and strEmailAddress go and how does it get called.

Sorry to sound so confusing with this. Any help would be appreciated.

Ken

"Rob Meade" wrote:
"Ken D." wrote ...
Is it even possible to achieve what I am trying to do? I am trying to
avoid
sending a blanket email to a single address and having someone filter them
from there.


Hi Ken,

If I'm following you correctly then yes...
In your code that handles the form being submitted...

strRepID = request.form("repid") ' replace this with the name of your
drop down list - I'm assuming it contains an ID for the rep?

' run a query against your database to return the email address - a
stored procedure to return it based on the rep id might be nice
' strEmailAddress = RS("RepsEmailAddress")

' send the email using the above string in the TO property
' (see this article for an example on sending CDO emails
http://www.aspfaq.com/show.asp?id=2339)

Hope this is of some help...you could tart it up a bit by doing some checks
to see if you returned a reps details or not and displaying a suitable
message if not, in addition your stored procedure could also get the reps
name and you could then on your confirmation page say "An email has been
sent to Mr A Rep" etc etc..

Regards

Rob


Jun 9 '06 #4

P: n/a
Mike,

I found the following code which appears to solve my problem but I am
getting a type mismatch error at the Response.Write(ParseBody(strBody)) line.

Here is the code:
**********************************************
<html>

<head>

<%
Function ParseBody(strText)
strText = Replace(strText, Chr(13), "<br>")
ParseBody = strText
End Function

Dim myConnString
Dim myConnection
Dim mySQL

myConnString = Application("Sample_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

mySQL= "INSERT INTO Employees "
mySQL= mySQL & "(FirstName,LastName,Address,City,Region,PostalCod e) "
mySQL= mySQL & "VALUES ('" & Request.Form("FirstName") & "','"
mySQL= mySQL & Request.Form("LastName") & "'"
mySQL= mySQL & ",'" & Request.Form("Address") & "'"
mySQL= mySQL & ",'" & Request.Form("City") & "','"
mySQL= mySQL & Request.Form("Region") & "','"
mySQL= mySQL & Request.Form("PostalCode") & "')"

myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody

strFrom="em***@someplace.com"
strTo=Request.Form("EMail")
strSubject = "Send to E-mail and Database"

strBody ="The following information was submitted:" & Chr(13)
strBody = strBody & Request.Form("FirstName") & " "
strBody = strBody & Request.Form("LastName")
strBody = strBody & Chr(13) & Request.Form("Address") & Chr(13)
strBody = strBody & Request.Form("City") & Chr(13)
strBody = strBody & Request.Form("Region") & Chr(13)
strBody = strBody & Request.Form("PostalCode") & Chr(13)
strBody = strBody & Chr(13) & "Thank you for submitting your data."

Set myCDONTSMail = CreateObject("CDONTS.NewMail")
myCDONTSMail.Send strFrom,strTo,strSubject,strBody
Set myCDONTSMail = Nothing
%>

</head>

<body bgcolor="#FFCC99">

<p><font face="Verdana" color="#FF0000"><b>Thank you for submitting your
information!<br>
</b></font><font face="Verdana" size="2">You will receive an e-mail
shortly. The e-mail was sent using the following information:</font></p>
<b><b><font face="Verdana" size="2">Sent To: <br>

<%
Response.Write Request.Form("EMail")
%>

From: Microsoft PSS Sample Page</font></b></p>

<p><b><font face="Verdana" size="2">Subject: Send to Database and
E-mail</font></b></p>

<p><b><font face="Verdana" size="2">Content:

<%
Response.Write(ParseBody(strBody))
%>

</font></b></p>
<hr noshade size="1" style="color: #000000">
<p> </p>

</body>

</html>
************************************************

"Mike Brind" wrote:
If you think about the logic flow of your process, it should be fairly
obvious. You need the rep's email address before you can send an email
to him/her, right? So the email generation code has to go at some
point after the code that successfully retrieves this information from
your database.

You have three actions to perform after you have retrieved the rep
info:
1. Send an email
2. Write to the db
3. Display a confirmation page.

I can't see that it matters in which order you code these actions.
None of them are dependent on the other, but all are dependent on
successful validation of the information submitted in the form.

--
Mike Brind

Ken D. wrote:
Rob,

Thanks for the reply. Not being a programmer, sometimes I am a bit
challenged. Let me ask you this. I have an asp page that I built in
Frontpage 2002 that upon submit, sends data to a SQL database and provides a
confirmation to the user. I want to initiate the email to the rep selected
in a combo box on the asp form at the same time the submit button is
selected. I have a stored procedure that returns the last entered rep (and
it works great). My question is, where do I insert your code in order to get
it to fire at the submit event. I understand the script goes on my asp page
but where does the strRepID and strEmailAddress go and how does it get called.

Sorry to sound so confusing with this. Any help would be appreciated.

Ken

"Rob Meade" wrote:
"Ken D." wrote ...

> Is it even possible to achieve what I am trying to do? I am trying to
> avoid
> sending a blanket email to a single address and having someone filter them
> from there.

Hi Ken,

If I'm following you correctly then yes...
In your code that handles the form being submitted...

strRepID = request.form("repid") ' replace this with the name of your
drop down list - I'm assuming it contains an ID for the rep?

' run a query against your database to return the email address - a
stored procedure to return it based on the rep id might be nice
' strEmailAddress = RS("RepsEmailAddress")

' send the email using the above string in the TO property
' (see this article for an example on sending CDO emails
http://www.aspfaq.com/show.asp?id=2339)

Hope this is of some help...you could tart it up a bit by doing some checks
to see if you returned a reps details or not and displaying a suitable
message if not, in addition your stored procedure could also get the reps
name and you could then on your confirmation page say "An email has been
sent to Mr A Rep" etc etc..

Regards

Rob


Jun 14 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.