Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old September 7th, 2008, 10:20 PM
Newbie
 
Join Date: Aug 2008
Posts: 6
Default 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:

Expand|Select|Wrap|Line Numbers
  1.   <form id="pipform" enctype="text/plain" action="mailto:info@planitperfect.net?subject=Plan it Perfect" method="post" onsubmit="javascript:return validateall(this);">
  2.     <fieldset style="border:none;">
  3.     <label for="">Name:</label><br />
  4.     <input type="text" id="name" name="name" /><br />
  5.     <label for="">Email:</label><br />
  6.     <input type="text" id="email" name="email" /><br />
  7.     <label for="area">Phone:</label><br />
  8.     <input type="text" id="area" name="area" size="3" maxlength="3" /> -
  9.     <input type="text" id="first3" name="first3" size="3" maxlength="3" /> -
  10.     <input type="text" id="last4" name="last4" size="4" maxlength="4" /><br />
  11.     <label for="list">How did you hear of us?</label><br />
  12.     <select id="list" name="list" name="Hear">
  13.     <option>---------</option>
  14.     <option>Friend</option>
  15.     <option>Internet</option>
  16.     <option>Flyer</option>
  17.     <option>Wedding</option>
  18.     </select>
  19.     <br />  
  20.     <label for="inquiry">Inquiry, Comment, or Suggestion:</label><br />
  21.     <textarea id="inquiry" name="inquiry" rows="3" cols="30" name="inquiry"></textarea><br /><br />
  22.     <input type="submit" id="submit" value="Submit" />
  23.     <input type="reset" id="reset" name="reset" />
  24.     </fieldset>
  25.   </form>
  26.  
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?
Reply
  #2  
Old September 8th, 2008, 06:45 AM
Newbie
 
Join Date: Aug 2008
Posts: 6
Default

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.
Reply
  #3  
Old September 8th, 2008, 10:18 AM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 348
Default

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).

Expand|Select|Wrap|Line Numbers
  1. 'Sending SMTP mail via port 25 using CDOSYS
  2. 'This VB sample uses CDOSYS to send SMTP mail using the cdoSendUsingPort option and specifying a SMTP host.
  3.  
  4. ' Note: It is recommended that all input parameters be validated when they are
  5. ' first obtained from the user or user interface.
  6. Private Sub SendMessage(strTo As String, strFrom As String)
  7.  
  8. 'Send using the Port on a SMTP server
  9. Dim iMsg As New CDO.Message
  10. Dim iConf As New CDO.Configuration
  11. Dim Flds As ADODB.Fields
  12. Dim strHTML
  13.  
  14. Set Flds = iConf.Fields
  15.  
  16. With Flds
  17.     .Item(cdoSendUsingMethod) = cdoSendUsingPort
  18.     .Item(cdoSMTPServer) = "yourmailserver.example.com"
  19.     'Use SSL to connect to the SMTP server:
  20.     '.Item(cdoSMTPUseSSL) = True
  21.     .Item(cdoSMTPConnectionTimeout) = 10
  22.     .Update
  23. End With
  24.  
  25. ' Build HTML for message body
  26. strHTML = "<HTML>"
  27. strHTML = strHTML & "<HEAD>"
  28. strHTML = strHTML & "<BODY>"
  29. strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
  30. strHTML = strHTML & "</BODY>"
  31. strHTML = strHTML & "</HTML>"
  32.  
  33. With iMsg
  34.     Set .Configuration = iConf
  35.     .To = strTo
  36.     .From = strFrom
  37.     .Subject = "This is a test CDOSYS message (Sent by Port)"
  38.     .HTMLBody = strHTML
  39.     '.TextBody = "This is the text body of the message..."
  40.  
  41.     .Send
  42. End With
  43.  
  44. ' cleanup of variables
  45. Set iMsg = Nothing
  46. Set iConf = Nothing
  47. Set Flds = Nothing
  48.  
  49. End Sub
  50.  
Sample taken from MSDN.

Hope this helps.

Best regards,

medicineworker
Reply
  #4  
Old September 8th, 2008, 10:56 AM
Newbie
 
Join Date: Aug 2008
Posts: 6
Default

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!
Reply
  #5  
Old September 9th, 2008, 02:29 PM
codegecko's Avatar
Moderator
 
Join Date: May 2007
Location: United Kingdom
Age: 21
Posts: 348
Default

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
Reply
  #6  
Old September 9th, 2008, 03:07 PM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 926
Default

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
Reply
  #7  
Old September 10th, 2008, 09:10 AM
Newbie
 
Join Date: Aug 2008
Posts: 6
Default

Hahaha.

Thanks for your help, I really appreciate it! I should be able to work this out now!
Reply
  #8  
Old October 1st, 2008, 10:39 AM
Newbie
 
Join Date: Oct 2008
Posts: 3
Default

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
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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.
Post your question now . . .
It's fast and it's free

Popular Articles