E-mail web response

G

Greg Maxey

I have a feedback form on my website to allow users to provide feedback.
Teh feedback form has fields for users to enter feedback and code to colect
the input and e-mail it to me. The problem is that if users fillout and
submit the form a feedback web page opens thannking them for the input. The
proplem is that if the user doesn't fill in an email address then the
results are not e-mailed.

Can someon tell me what I am missing here? Thanks.

The page is:
http://gregmaxey.mvps.org/User_Feedback.asp

The code of the response.asp is:


<%@ Language = VBscript %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
<title>Feedback Confirmation</title>
<meta name="Microsoft Theme" content="expeditn 1011, default">
</head>

<body>

<p align="center">

<!--webbot bot="Navigation" S-Type="banner" S-Orientation="horizontal"
S-Rendering="graphics" --><%
Dim MessageType, Subject, SubjectOther, Comments
Dim Username, UserEmail, ContactRequested
Dim MyBody, Mymail

'grab data from the form

MessageType= Request.Form("MessageType")
Subject= Request.Form("Subject")
SubjectOther= Request.Form("SubjectOther")
Comments= Request.Form("Comments")
Username= Request.Form("Username")
UserEmail= Request.Form("UserEmail")
ContactRequested= Request.Form("ContactRequested")
%>

</p>

<p><font size="6">T</font><font size="4">hank you for your interest in my
website and for your valuable feedback.&nbsp; For confirmation, the feedback
you
submitted was:</font></p>

<p>
<b>Message Type: <%= MessageType %> </b><br>
<b>Subject: <%= Subject%> </b><br>
<b>Subject Other: <%=SubjectOther %> </b><br>
<b>Comments: <%= Comments%></b> <br>
<b>Your Name: <%= Username%></b> <br>
<b>Your Email: <%= UserEmail%></b> <br>
<b>Contact Requested: <%=ContactRequested %></b>
</p>
<p><font size="4">While I value your feedback,&nbsp; please remember that I
that
I can't treat user feedback as&nbsp; a support request.&nbsp; I am very
active in the
Microsoft Word
newsgroups and will always try to answer any question that you post
there.</font></p>
<p><font size="4">If you'd like to change and resubmit the information you
sent,
feel free to <a href="User_Feedback.asp">go back</a> to the User Feedback
page.&nbsp; <a href="Index.htm">Click here</a> to go back to my home
page.&nbsp; Once again, thank
you very much!</font></p>
<p><font size="4">Don't forget &quot;donations&quot; large and small are
always welcome!!</font></p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd0" value="_s-xclick">
<p align="center">
<input type="image"
src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0"
name="submit0" alt="Make payments with PayPal - it's fast, free and
secure!">
<input type="hidden" name="encrypted0" value="-----BEGIN
PKCS7-----MIIG7QYJKoZIhvcNAQcEoIIG3jCCBtoCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYCOQoD6ZLVLUWWhzQEP0fKk/zig2snv7ml5Zo8QEzSXB4yWCw4+oBcK5NTqQq3YO2/vuPHZfBtEEK7AwJVWgyPDKnxHgieP1XRKppZQxP6/Ln1QQwx/HdTZP6Cj+g21eV+F99Zk9CuISk/0BTJ/Tl5VIIKoaR+MC1AmcEOvPK3kXTELMAkGBSsOAwIaBQAwawYJKoZIhvcNAQcBMBQGCCqGSIb3DQMHBAhyCV/crOfQ+YBItWZftwYkhKdCdWZir3JaYjRZw00m+WDMmIqWEmBcymBV5aEj5cFQ8k6N33Uv7hTk4+Ekzgmwh02fejkJMLBMHLj/MYDaQIXAoIIDhzCCA4MwggLsoAMCAQICAQAwDQYJKoZIhvcNAQEFBQAwgY4xCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLUGF5UGFsIEluYy4xEzARBgNVBAsUCmxpdmVfY2VydHMxETAPBgNVBA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UzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC1BheVBhbCBJbmMuMRMwEQYDVQQLFApsaXZlX2NlcnRzMREwDwYDVQQDFAhsaXZlX2FwaTEcMBoGCSqGSIb3DQEJARYNcmVAcGF5cGFsLmNvbQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMDUwMzE2MjEwNDM2WjAjBgkqhkiG9w0BCQQxFgQULWjdnK1B3gYnjVWHlNYnhP4fUnYwDQYJKoZIhvcNAQEBBQAEgYCs25Nn9HBOV5g+NBNdH7dtFR3Og/y9C5uJXgpjwpbje+4myHoXtH0wZwdQGZ8pJ/daqlQPx/260HIdp2dVVoxILs8vLh1XOmK9Y3q2oE/fXx7xaIiW1KRzg33mJaqFDrTS3WzRZyK9QsxL6bHgywO0Dw4JFRyliXUjPYXnCvFWMw==-----END
PKCS7-----
">
</p>
</form>
<p>&nbsp;</p>
<p>
&nbsp;</p>
<p>
<br>
</p>

<%
'create the email and send it

Set myMail=CreateObject("CDO.Message")

Mymail.From= UserEmail
Mymail.To= "(e-mail address removed)" 'change to your email
Mymail.Subject= "Website Comments from " & Username

MyBody = "Comments from the web site." & vbCrLf & vbCrLf
MyBody = MyBody & "Comments: " & Comments & vbCrLf & vbCrLf
MyBody = MyBody & "Username: " & Username & vbCrLf & vbCrLf
MyBody = MyBody & "UserEmail: " & UserEmail & vbCrLf & vbCrLf
MyBody = MyBody & "ContactRequested: " & ContactRequested & vbCrLf

myMail.TextBody= MyBody

Const cdoSchema = "http://schemas.microsoft.com/cdo/configuration/"
Mymail.Configuration.Fields.Item(cdoSchema & "sendusing") = 2
Mymail.Configuration.Fields.Item(cdoSchema & "smtpserver") = "mail.mvps.org"
Mymail.Configuration.Fields.Item(cdoSchema & "smtpserverport") = 25
Mymail.Configuration.Fields.Update

Mymail.Send
set Mymail =nothing

%>
</body>
</html>
 
G

Greg Maxey

Wow, that was a poorly written description of the problem. :-(

Let me try again. The problem is if a user fills out the feedback without
providing thier e-mail address the Feedback confirmation page opens thanking
them for their feeback but the actual feedback isn't mailed to me. The
users is left thinking that they have submitted feedback when nothing was
sent.

How can I change the code so that the feedback is e-mailed to me without
their e-mail information or the user gets a prompt requesting their e-mail
address information.

Thanks.
 
T

Tom Gahagan

In the form properties set it up to send it to your email address.

As for the email address field.... if you wan to make sure it is filled in
just go to form field properties... validate.... and check the required
check box. If they leave it out... they will be prompted to fill it in. Of
course you will probably want to warn them that this is a required field as
they are filling out the form and you will probably also want to assure them
as to the privacy of their email address and how you will use it. Just a
thought anyway........ :)

Best to you.......
Tom Gahagan
 
G

Greg Maxey

Tom,

Thanks for your suggestions. I avoided using the send to my email address
to prevent the open display of my address in the source code. With lots,
and I mean lots, of help from other people in this group I managed to put
together a script to get the form contents e-mailed to me.

The problem was if the user left the e-mail field blank, then a message was
never sent. I didn't want to go into all the "privacy" warnings and such
and wanted to let the user leave the email field blank if they wanted, fill
it in wit a valid address, or put anything there. Whatever they did didn't
matter as long as the message was sent.

I finally put the following in my script and it seems to be working:

If Len(UserEmail) = 0 Then
UserEmail = "Not provided"
End if
If Len(UserName) = 0 Then
UserName = "Not provided"
End if
 
P

p c

Hi Greg, seems you are getting the hang of it. What you have is fine

Hereis more info on 2 things.

1. Anything you write as ASP code will not show up as HTML source code
unless it is created to be text/html for the browser to use. This is
because the ASP script is run at the server and then the resultant page
is served to the client. I.e. your email address cannot be available
unless it is displayed to the browser in the HTML source code.

2. The server by design will not send any email if the FROM address
field is empty. What you want to do is called form validation. You have
3 options

A. Use FP in FP webs to validate the form field. FPSE will check and
will not submit the form if it's not validated.

In FP normal view, right click the form field for UserEmail and choose
Form Field Validation. In the dialog enter a display label "email"; for
data type, choose Text; for length, checkoff required and enter min.
length of 7 (e.g. for (e-mail address removed)). and click OK.

B. Using ASP at the server. The page will be submitted to the server.
And you have code in the response page to validate it.

For your example, you plan will work. Here's an improved way for basic
email validation. Teh code can be reused the code in other pages.

'Add this function in the ASP script after the DIM statements
Function validEmail(strEmail)
IF UserEmail <> "" AND inStr(strEmail,"@") <> 0 _
AND inStr(strEmail,".") <> 0 Then
validEmail=True
Else
validEmail=False
End If
End Function 'validEmail

'Add in ASP code where you want to check
If validEmail(UserEmail)=False Then
Response.Write "<p>Please click Back on your browser and enter a
valid email address.</p>" 'This is one line
' Add here code to skip sending of email
Else
' code to send email
End If

C. Javascript validation at the client in the form page.

Good luck
....PC
 
G

Greg Maxey

PC,

Thanks for the additional details. My primary objective was to keep my
e-mail address out of the source code available to users. That objective is
met.

I don't really care if the user provides a valid e-mail address (at least I
don't think I care). I realize the method that I am currently using does
not "validate" an e-mail address, but it does 'trick' the system and result
in the user comments being forwarded to me if 1) they fill in a valid
address. 2) leave the field empty and 3) type in a string a garbage.

I may go back in and change the code that if the user checks the "please
contact me" box then perform a "validate."

You guys in this group are a great help. You tend to start out at the
graduate level, but if the OP whines, grovels, or complains about having to
catch his own fish then you are willing to step down to his level. Great
stuff. Thanks again.
 
G

Greg Maxey

PC,

I have gone your option 2 route to validate the e-mail address. I only want
the validation to be put to use IF the user checks the box requesting
contact. Otherwise I don't care if an e-mail address is supplied or not.

Using this line from your example:
Response.Write "<p>Please click Back on your browser and enter a
valid email address.</p>"
Produced the undesireable effect of having that text displayed and the
normal confirmation text which could be confusing.

Unfamiliar with ASP as I am, I experimented and came up with the following
process:

If ContactRequested="Yes" And validEmail(UserEmail)=False Then
%>
<p>You requested that I contact you but you didn't provide a valid e-mail
address. Please click Back on your browser and enter a valid email
address.</font></p>
<%
Else
Mymail.Send
set Mymail =nothing
%>
</p>Thank you for your interest in my blah blah
<%
End If
%>

This seems to be working.

Using this process does result in both conditions being shown in design and
preview mode. I think that is to be expected. Question - Is the process I
am using a conventional process for displaying Response A for one condition
Or Response B for another? Is there a better or more conventional way of
doing this.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top