472,354 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

System generated email...

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
4 2244
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
12
by: R | last post by:
Hello everybody. I'm writing my own Content System in PHP5. I've written so far main classes for handling DB connections, XML, XForms and Sessions. But I've got problem with one thing - it's...
13
by: Jon Agiato | last post by:
Hello, I am sure this problem is easy to spot but I have been at this project all day and the frustration has finally overcome me. I am using this function in order to produce a standard normal...
20
by: Adrian | last post by:
What does this error mean? Could not access CDO Message Object. Many thanks.
2
by: Ben | last post by:
I have several pages written in aspx, but sometime the aspx page return the following error. And it hapeen, the whole web application gives this error, that means all the aspx files get affected....
1
by: chintu rana via DotNetMonster.com | last post by:
An unhandled exception of type 'System.ArithmeticException' occurred in system.drawing.dll Additional information: Overflow or underflow in the arithmetic operation. if i run vb.net...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
9
by: Xah Lee | last post by:
REQUIREMENTS FOR A VISUALIZATION SOFTWARE SYSTEM FOR 2010 Xah Lee, 2007-03-16 In this essay, i give a list of requirements that i think is necessary for a software system for creating...
4
by: Laurence Breeze | last post by:
I wonder if anyone can help ... Today I tried to create another non-clustered index on a table. This failed as I apparently already had 249 non-clustered indexex on the table. Looking at the...
2
by: =?Utf-8?B?TmF0aGFuIFdpZWdtYW4=?= | last post by:
Hi, I am wondering why the .NET Framework is quite different from Win32 API when it comes to displaying system modal message boxes. Consider the four following types of system modal message...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.