 | 
September 7th, 2008, 10:20 PM
| | Newbie | | Join Date: Aug 2008
Posts: 6
| | Forum email send with ASP
Hi guys,
I'm a pretty basic coder with very limited skills. I've been researching this question everywhere and I can't find anything that works.
What I'm trying to do is simply send a form which is filled out on their webpage, to their email address. Currently I am using a mailto: function which I desperately want to avoid. Also, if it helps this site is hosted through godaddy (windows package), if that makes any difference. Here is the HTML for my form: -
<form id="pipform" enctype="text/plain" action="mailto:info@planitperfect.net?subject=Plan it Perfect" method="post" onsubmit="javascript:return validateall(this);">
-
<fieldset style="border:none;">
-
<label for="">Name:</label><br />
-
<input type="text" id="name" name="name" /><br />
-
<label for="">Email:</label><br />
-
<input type="text" id="email" name="email" /><br />
-
<label for="area">Phone:</label><br />
-
<input type="text" id="area" name="area" size="3" maxlength="3" /> -
-
<input type="text" id="first3" name="first3" size="3" maxlength="3" /> -
-
<input type="text" id="last4" name="last4" size="4" maxlength="4" /><br />
-
<label for="list">How did you hear of us?</label><br />
-
<select id="list" name="list" name="Hear">
-
<option>---------</option>
-
<option>Friend</option>
-
<option>Internet</option>
-
<option>Flyer</option>
-
<option>Wedding</option>
-
</select>
-
<br />
-
<label for="inquiry">Inquiry, Comment, or Suggestion:</label><br />
-
<textarea id="inquiry" name="inquiry" rows="3" cols="30" name="inquiry"></textarea><br /><br />
-
<input type="submit" id="submit" value="Submit" />
-
<input type="reset" id="reset" name="reset" />
-
</fieldset>
-
</form>
-
I've tried a few different options, but when it sends I usually get something like "post not allowed for request.asp."
So I'm pretty stuck, any help would be appreciated. At least a push in the right direction?
| 
September 8th, 2008, 06:45 AM
| | Newbie | | Join Date: Aug 2008
Posts: 6
| |
Also, I forgot to mention the form is already validated through JavaScript. Plus if it helps, I also tried doing this send through PHP which I later found out isn't supported by the web host.
| 
September 8th, 2008, 10:18 AM
|  | Moderator | | Join Date: May 2007 Location: United Kingdom Age: 21
Posts: 348
| |
Hi SAF22,
Firstly, welcome to Bytes IT Community!
Secondly, you can either use ASP or PHP mail functions (depending on whether your GoDaddy host account supports it). It simply involves setting your form method to POST, then setting the action attribute on the form to the script that will send the mail for you.
In ASP, the easiest way to send mail is using the Windows controls CDO/CDOSYS (on Windows Server 2003) or CDONTS (on NT4/Win2K systems). -
'Sending SMTP mail via port 25 using CDOSYS
-
'This VB sample uses CDOSYS to send SMTP mail using the cdoSendUsingPort option and specifying a SMTP host.
-
-
' Note: It is recommended that all input parameters be validated when they are
-
' first obtained from the user or user interface.
-
Private Sub SendMessage(strTo As String, strFrom As String)
-
-
'Send using the Port on a SMTP server
-
Dim iMsg As New CDO.Message
-
Dim iConf As New CDO.Configuration
-
Dim Flds As ADODB.Fields
-
Dim strHTML
-
-
Set Flds = iConf.Fields
-
-
With Flds
-
.Item(cdoSendUsingMethod) = cdoSendUsingPort
-
.Item(cdoSMTPServer) = "yourmailserver.example.com"
-
'Use SSL to connect to the SMTP server:
-
'.Item(cdoSMTPUseSSL) = True
-
.Item(cdoSMTPConnectionTimeout) = 10
-
.Update
-
End With
-
-
' Build HTML for message body
-
strHTML = "<HTML>"
-
strHTML = strHTML & "<HEAD>"
-
strHTML = strHTML & "<BODY>"
-
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
-
strHTML = strHTML & "</BODY>"
-
strHTML = strHTML & "</HTML>"
-
-
With iMsg
-
Set .Configuration = iConf
-
.To = strTo
-
.From = strFrom
-
.Subject = "This is a test CDOSYS message (Sent by Port)"
-
.HTMLBody = strHTML
-
'.TextBody = "This is the text body of the message..."
-
-
.Send
-
End With
-
-
' cleanup of variables
-
Set iMsg = Nothing
-
Set iConf = Nothing
-
Set Flds = Nothing
-
-
End Sub
-
Sample taken from MSDN.
Hope this helps.
Best regards,
medicineworker
| 
September 8th, 2008, 10:56 AM
| | Newbie | | Join Date: Aug 2008
Posts: 6
| |
Thank you for the welcome medicineworker!
So, what I did was take that code and placed it onto an .asp page (called test.asp). I changed my form action to action="test.asp", and set method to post (which it already was). I am not too sure what is going on with the script, but I wanted to see if I could at least get some kind of positive response . What happened is the same thing with the PHP actually. Here is what happens after the submit button:
Method POST is not allowed by /test.asp
This sounds to me like the web server isn't allowing ASP as well as PHP. Is this the case, or am I way off?
I'm very sorry, please bare with me as I am extremely new to this language. I have done some research on it and getting the feel for it, but still far from understanding!
| 
September 9th, 2008, 02:29 PM
|  | Moderator | | Join Date: May 2007 Location: United Kingdom Age: 21
Posts: 348
| |
Hi there,
Yes, that sounds about right. It would appear that your web server refuses to accept HTTP POST requests for most, if not all, server-side languages. If this is a third-party host then you need to speak to them to see if they will relax the ASP permissions. If they won't, then use the GET method instead, and change the code to get Request.QueryString("my-form-field-name") instead.
FYI (a little background) - every time you request a page, an HTTP request is made, using one of two methods - GET or POST. GET simply requests the requested URL from the server, and any additional data is submitted as a querystring (e.g. test.asp?message-title=Hello%20world&message-body=This%20is%20a%20test) - notice the way it's encoded so even spaces can be transmitted safely.
POST sends data WITH the request, in the headers, and is therefore "invisible" to the user. POST carries security issues for third-party hosting companies as they suspect every file upload is a virus that will bring down their server farm!
In this instance, unless you have a specific reason to use POST (secure, confidential messages) then simply switch to GET, it GET's you round the problem (gotta love my puns!)
Best regards,
medicineworker
| 
September 9th, 2008, 03:07 PM
|  | Moderator | | Join Date: Jan 2008 Location: Winchester, UK
Posts: 926
| | Quote: |
Originally Posted by medicineworker it GET's you round the problem (gotta love my puns!) | You've got to love that kind of punning! Keep 'em coming...
Dr B
| 
September 10th, 2008, 09:10 AM
| | Newbie | | Join Date: Aug 2008
Posts: 6
| |
Hahaha.
Thanks for your help, I really appreciate it! I should be able to work this out now!
| 
October 1st, 2008, 10:39 AM
| | Newbie | | Join Date: Oct 2008
Posts: 3
| |
You might also want to try the mMail library found here:
http://www.virtualthinking.com/loadhtml.php?where=scripts&what=art_show.php&db_ta rget=00000000023
|  | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 204,687 network members.
|