i have a form i'm using and would like to embed it into my site. i've set up a test location on my godaddy server which is asp enabled. my problem is that when I go to submit my completed for, I get 'page cannot be displayed' error. Here is my form: http://www.plymouthtravelvet.com/test/contact.htm here is my asp code: <% ' declare variables Dim EmailFrom Dim EmailTo Dim Subject Dim Name Dim Address Dim City Dim State Dim PostCode Dim Tel Dim Department Dim Website ' get posted data into variables EmailFrom = "xxxx@gmail.com" EmailTo = "xxxxx@gmail.com" Subject = "xxxxxx" Name = Trim(Request.Form("Name")) Address = Trim(Request.Form("Address")) City = Trim(Request.Form("City")) State = Trim(Request.Form("State")) PostCode = Trim(Request.Form("PostCode")) Tel = Trim(Request.Form("Tel")) Department = Trim(Request.Form("Department")) Website = Trim(Request.Form("Website")) ' validation Dim validationOK validationOK=true If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom) ' prepare email body text Dim Body Body = Body & "Name: " & Name & VbCrLf Body = Body & "Address: " & Address & VbCrLf Body = Body & "City: " & City & VbCrLf Body = Body & "State: " & State & VbCrLf Body = Body & "PostCode: " & PostCode & VbCrLf Body = Body & "Tel: " & Tel & VbCrLf Body = Body & "Department: " & Department & VbCrLf Body = Body & "Website: " & Website & VbCrLf ' send email Dim mail using System.Web.Mail; private void SendEmail() { const string SERVER = "relay-hosting.secureserver.net"; MailMessage Mail = new System.Web.Mail.MailMessage(); mail.To = EmailTo mail.From = EmailFrom mail.Subject = Subject mail.Body = Body SmtpMail.SmtpServer = SERVER; SmtpMail.Send(Mail); Mail = null; // free up resources } ' redirect to success page Response.Redirect("ok.htm?" & EmailFrom) %> some of this was taken from here http://help.godaddy.com/article.php?article_id=1073 Why won't the form send me an email? what changes should i make to my asp code? thanks!
you need to close your if... then statement. If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom) ' prepare email body text Code (markup): should be If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom) end if ' prepare email body text Code (markup): also - looks like you switched to php here: private void SendEmail() { const string SERVER = "relay-hosting.secureserver.net"; MailMessage Mail = new System.Web.Mail.MailMessage(); mail.To = EmailTo mail.From = EmailFrom mail.Subject = Subject mail.Body = Body SmtpMail.SmtpServer = SERVER; SmtpMail.Send(Mail); Mail = null; // free up resources } Code (markup): don't know what's going on with that - but that's php code. VG
why don't you use this simple script 'send emails Set myMail = CreateObject("CDO.Message") myMail.Subject = "Your subject here" myMail.From = "Mr. X <xxx@xxxx.xxx>" myMail.To = "Mr. Y <xxx@xxxx.xxx>" myMail.HTMLBody = strBody myMail.Send set myMail=nothing session("alert") = "Your mail was sent." response.redirect "YourContactPage.asp" response.end Code (markup):
you have written the wrong code, if you are using asp only. it seems that u are mixing the code of asp .net in asp, which would't work. its very easy to send email from an asp page to an email addres, if u need the code then let me know, once i wrote it for my website and it worked properly.
WOW, are you mixing Classic ASP (VBScript), ASP.NET (VB Backend), and ASP.NET (C# Backend)? Please do it all in one certain language to get it to work