Forum Moderators: open

Message Too Old, No Replies

Help With Emailing Form Results to an Address Entered by The User

emailing to a form variable - entered by user

         

JillGuttu

2:43 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Can anyone help me figure out how to send an email to an email address entered by a user into a form. I've tried using <%=request.form("mgremail")%> in the SendTo field of the email code. This does not work.

I know you experienced gurus will cringe, but, i used frontpage and created an email form: here's the code:

<!--webbot bot="SaveResults" S-Email-Format="TEXT/PRE"
S-Email-Address="<%=request.form("mgremail")%>" B-Email-Label-Fields="TRUE"
B-Email-Subject-From-Field="FALSE"
S-Email-Subject="Your Employee has started the New Hire Orientation Process"
S-Builtin-Fields S-Form-Fields="fname lname mgremail "
U-Confirmation-Url="confirm.htm" -->

Thanks so much! I really need this help to finish a project.

BlobFisk

2:51 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome [webmasterworld.com] to WebmasterWorld, JillGuttu!

The <%=...%> is shorthand for response.write. You could create a variable for the email address and then call the variable in the body. So, above your all your html you could put:


<%@ Language=VBScript %>
<% option explicit %>

<%
Dim email
email = Request.Form("mgremail")

%>

And then use <%=email %> instead of what you currently have in the body of the page.

You will also need to save your page as a .asp page.

<edit>Code error fixed</edit>

[edited by: BlobFisk at 4:37 pm (utc) on April 11, 2003]

jimmykav

3:02 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



<% %> are not short hand for response.write - they are short hand for <script...> </script>

JillGutu seems to me using a combination of asp and FrontPage bots.

BlobFisk is right about needing to have the file end in .ASP otherwise the scripts wont be executed.

BlobFisk

3:51 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey jimmykav,

Just to clarify, in my post I said that <%=...%> is shorthand for response.write - the '=' being the important bit!

jimmykav

3:54 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Ooopps - apologies BlobFisk. It has been a long day in front of the monitor :(

Just about to take off for the weekend though! ;)

BlobFisk

4:26 pm on Apr 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a good one and enjoy!

JillGuttu

6:25 pm on Apr 11, 2003 (gmt 0)

10+ Year Member



Hi All. Thanks for responding so quickly.

I have decided to try this instead.. but it's still not working - not sending the mail nor am i getting either the success or failed message.

<%
Dim blnMailSuccess

Set MyMail = Server.CreateObject("eArchNonConfig.SendMail")
If err.number <> 0 Then
Call HandleError()
End If


Response.Write Request("SendTo")
Response.Write Request("SendFrom")
Response.Write Request("SendCC")
Response.Write Request("SendBCC")
Response.Write Request("Subject")
Response.Write Request("BodyText")

Response.end

blnMailSuccess = MyMail.SendMail(Request("SendTo"), Request("SendFrom"), Request("SendCC"), Request("SendBCC"), Request("Subject"), Request("BodyText"))

Set MyMail = Nothing

If err.number <> 0 Then
Call HandleError()
End If

If blnMailSuccess = True Then
Response.Write ("Your Mail Has Been Sent")
Response.End
End If

Sub HandleError()
If blnMailSuccess = False Then
Response.Write ("Email has failed")
End If
End Sub
%>

any ideas?

jimmykav

11:51 am on Apr 12, 2003 (gmt 0)

10+ Year Member



I am not familiar with the mail server you are using:

Set MyMail = Server.CreateObject("eArchNonConfig.SendMail")

I use the MS CDO objects:

set cdo = Server.CreateObject("CDONTS.NewMail")

aspdaddy

12:21 pm on Apr 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why don't you just remove all the error handling and see where it fails?