1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

asp email form on godaddy

Discussion in 'C#' started by nfl2k2, May 17, 2006.

  1. #1
    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!
     
    nfl2k2, May 17, 2006 IP
  2. vectorgraphx

    vectorgraphx Guest

    Messages:
    545
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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
     
    vectorgraphx, May 18, 2006 IP
  3. ludwig

    ludwig Notable Member

    Messages:
    2,253
    Likes Received:
    66
    Best Answers:
    0
    Trophy Points:
    225
    #3
    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):
     
    ludwig, May 18, 2006 IP
  4. surfnearnzone

    surfnearnzone Well-Known Member

    Messages:
    1,492
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Have you checked the folder permissions and is the cdo installed on your server ?? :)
     
    surfnearnzone, Jun 10, 2007 IP
  5. kashif.nazar

    kashif.nazar Peon

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    kashif.nazar, Jun 10, 2007 IP
  6. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #6
    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 :)
     
    ccoonen, Jun 12, 2007 IP