|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
#1 |
|
Member (5 bit)
Join Date: Oct 2005
Posts: 23
|
I'm new to VBscript, but I've learned the basics... that being said, I need a VBscript that will process an HTML form and email it.
I made one in PHP, but the hosting company I'm with only supports ASP and I thought VBscript seemed easier to learn than JavaScript. I need it to just pick up: 1) Name 2) E-mail 3) Subject 4) Message And if its possible, have the Subject as a drop menu.. and whatever subject/topic you choose, the script sends the e-mail to a specified e-mail address. Thanks |
|
|
|
|
|
#2 |
|
Member (5 bit)
Join Date: Oct 2005
Posts: 23
|
Ok... so far I have this as the form code on one page named test.html
HTML Code:
<html> <head> <title>test</title> </head> <body> <center> <form method="post" action="mail.asp" name="form"> <table border="0"> <tr> <td align="right"> Name: </td> <td><input type="text" id="name" name="name" size="20"></td> </tr> <tr> <td align="right">E-mail: </td> <td><input type="text" id="email" name="email" size="20"></td> </tr> <tr> <td align="right">Topic: </td> <td><input type="text" id="topic" name="topic" size="20"></td> </tr> <tr> <td align="right" valign="top">Message:</td> <td><textarea cols="40" wrap="virtual" rows="3" name="message"></textarea></td> </tr> <tr> <td> </td><td height="40"><input type="submit" value="Submit"> <input type="reset" value="Clear"></td> </tr> </table> </form> </center> </html> HTML Code:
<%@language="VBScript"%> <%Option Explicit%> <html> <head> <title>mail.asp</title> </head> <body bgcolor="#ffffff" style="margin-left: 10%; margin-right: 10%;"> <% dim strSubject, strName, strEmail, strNoEmail, strMsg, strText strEmail = Trim(Request.form("email")) if strEmail <> "" then strNoEmail = "No Email Given" end if strName = Request.form("name") strSubject = Request.form("topic") strMsg = Request.form("message") strText = "E-mail from: " & strName & vbCrLf & _ " Concerning: " & strSubject & vbCrLf & _ " Here is their message: " & strMsg & vbCrLf & _ " You can reply to " & strName & " at " & strEmail send_email() function send_email() Dim objMail Set objMail = Server.CreateObject("CDO.Message") objMail.To = "test@test.com" objMail.From = strEmail objMail.Subject = strSubject objMail.TextBody = strText objMail.Send Set objMail = Nothing if err.number > 0 then response.write "Errors were encountered in sending your e-mail message. "&_ "Please try again, or contact the <a href='mailto:test@test.com'>webmaster</a>" else strMsg = replace(strMsg,vbcrlf,"") response.write "<h3>Thank you</h3>" &_ "Your information was submitted as follows:" &_ "Name: " & strName & "" &_ "E-mail Address: " & strEmail & "" &_ "Message: " & strMsg & "" &_ "<a href='index.html'>Return to Main here</a>" end if end function %> </body> </html> |
|
|
|
|
|
#3 |
|
Member (7 bit)
Join Date: Jun 2005
Posts: 85
|
does it have to be a .asp file extension? or can you use an .aspx extension? therefore you can use ASP.NET rather than regular ASP. If you feel more comfortable with a language such as vb or c#, you can use that as your programming language for ASP.NET
|
|
|
|
|
|
#4 |
|
Member (5 bit)
Join Date: Oct 2005
Posts: 23
|
Yes, the hosting company supports both ASP and ASP.NET. I'm only slightly familiar with VBscript, not at all with C#. So, which ever one, ASP or ASP.NET, is best for my needs I will use.
|
|
|
|
|
|
#5 |
|
Member (7 bit)
Join Date: Jun 2005
Posts: 85
|
ASP.NET also supports VB if u know that language
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|