Click to See Complete Forum and Search --> : Email Address Post in ASP


petrocan
05-12-2003, 09:49 AM
Just wondering if there is a way I can create a TEXT field within a form that would ask for an email address and when the user hits the SEND button it would put that email address with the addresses specified within my ASP script?

I need to be done so that the user can first see who the request went to, but second, it owuld allow the user to reply to the addresses specified if something changed.

Any help would be appreciated?

sheila
05-12-2003, 11:14 AM
Can you be more specific? What are you doing when you process the form results? Sending mail/storing data? And what addresses specified in your ASP script?

petrocan
05-12-2003, 11:28 AM
Sorry...no problem...

The input fields are posted to the body of the email and the specified addresses are those I've specified with...

objMail.AddAddress "abc@def.com"

What I need know is if the user inputs their email address in a text field on the form, is there a function/script within ASP that can say grab the data from this input field and put it into the TO: or "objMail.Address" function of my ASP script.

So basically instead of having the input fields post to the body, can I have one particular input field post to the TO: portion of the email?

sheila
05-12-2003, 11:32 AM
Is this what you're after?

extraEmail = request.form("NameOfEmailInput")

petrocan
05-12-2003, 11:36 AM
Sorry Sheila, I a ASP newbie/moron, whatever you want to call me...what does that function do and where would I apply it in my ASP script? Here is the script I'm using:

<%
Option Explicit
Response.Expires = 0

' Call dumpForm
' Response.End

' -- email object
Dim objMail, theBody

Set objMail=Server.CreateObject("Persits.MailSender")
objMail.Host="pcaxs04"

objMail.From="abc@def.com"
objMail.Subject="Details"
objMail.AddAddress "abc@def.com"

objMail.isHTML = True
objMail.Body=GenTheBody()
objMail.Send
Set objMail = Nothing
Response.Redirect("index.htm")
Response.End

Sub dumpForm()
Dim Item
For Each Item in Request.Form %>
Control name '<% = Item %>'
= '<% = Request.Form(Item) %>'<BR>
<% Next
End Sub

Function dumpFormToMsg()
Dim Item, msg
msg = ""
For Each Item in Request.Form
msg = msg & "'" & Item & "' = '" & Request.Form(Item) & "'" & vbCrLf
Next
dumpFormToMsg = msg
End Function

%>
<html>
<head><title>Details</title></head>
<body>
<%
Function GenTheBody
Dim msg
msg = "<b><u>Details</b></u><br>" & vbCrLf & vbCrLf
msg = msg & "Field One" & Request("ONE") & vbCrLf & "<br>"
msg = msg & "Field Two" & Request("TWO") & vbCrLf & "<br>"
GenTheBody = msg
End Function
%>
</body>
</html>

sheila
05-12-2003, 05:26 PM
I feel like the blind leading the blind here so if anyone else cares to step in and point out any glaring mistakes/omissions please do!

Here goes. First you need to make sure that your email input has a name, eg.

<input name="email" type="text" size="25" />


Then you can reference it direct when you process the form data:


' Call dumpForm
' Response.End


' -- users email address Dim userEmail
userEmail = request.form("email")



And add it to your 'To' list using another AddAddress instruction:


' -- email object
Dim objMail, theBody

Set objMail=Server.CreateObject("Persits.MailSender")
objMail.Host="pcaxs04"

objMail.From="abc@def.com"
objMail.Subject="Details"
objMail.AddAddress "abc@def.com"
objMail.AddAddress userEmail


You might find this page useful:
http://www.domaindlx.com/aspemail/manual.htm

petrocan
05-13-2003, 08:46 AM
If you were here I'd kiss you Sheila, this works great and I love that its not complicated. LOL.

I really appreciate your help.

sheila
05-14-2003, 02:36 PM
You're welcome!