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 FormMail error

Discussion in 'C#' started by arstewar, Mar 22, 2009.

  1. #1
    Hey, I've been trying to get a form mailer to work for a while now, always ends up in errors, the latest I have tried to use comes from BrainJar (http://www.brainjar.com/asp/formmail/default.asp).

    My error is:
    Server object error 'ASP 0177 : 800401f3'

    Server.CreateObject Failed

    /ohlandproperties/formmail.asp, line 482




    Here is line 482 (in red):

    'Send email (ASPMail version).
    if mailComp = "ASPMail" then
    set mailObj = Server.CreateObject("SMTPsvg.Mailer")
    mailObj.RemoteHost = smtpServer
    mailObj.FromAddress = fromAddr
    for each addr in Split(recipients, ",")
    mailObj.AddRecipient "", Trim(addr)
    next
    if ccToAddr <> "" then
    mailObj.ReplyTo = Trim(ccToAddr)
    mailObj.AddCC "", Trim(ccToAddr)
    elseif replyToAddr <> "" then
    mailObj.ReplyTo = Trim(replyToAddr)
    end if
    mailObj.Subject = subject
    mailObj.ContentType = "text/html"
    mailObj.BodyText = body
    if not mailObj.SendMail then
    SendMail = "Email send failed: " & mailObj.Response & "."
    end if
    exit function
    end if



    I'm relatively new to this, any explanation would be most appreciated!
     
    arstewar, Mar 22, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    camjohnson95, Mar 22, 2009 IP
  3. foreststone

    foreststone Peon

    Messages:
    1,355
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    contact your host suplyer, maybe some something wrong on your host system.
    otherwise you need change your script to fit the system.
     
    foreststone, Mar 22, 2009 IP
  4. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    @ foreststone

    My host supplier, GoDaddy, will no longer help because they don't deal with third party coding (they are pretty worthless, I've tried to get something out of them numerous times). They say that this should work, that there is nothing else I need from them besides the smtp server name, unfortunately still an error.
     
    arstewar, Mar 22, 2009 IP
  5. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    @ camjohnson95

    Thanks, I wasn't sure what to do from the w3schools site, so I searched "A Generic Form-to-Email Script Using CDOSYS (ASP) by Mark Voss" (I can send links yet, but just in case you want to google the page).

    Looked to be simple enough, only one edit and that was to put my email in, unfortunately, an error.


    The error:

    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /ohlandproperties/cdosys.asp, line 12

    For Field = 1 to Request.Form.Count - 3
    ----^


    The code:

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    </head>

    <body>

    <%
    For Field = 1 to Request.Form.Count - 3
    FieldName = Replace(Request.Form.Key(Field),"_"," ")
    FieldValue = Request.Form.Item(Field)
    Body = Body & FieldName & ": " & FieldValue & VbCrLf
    Next
    'Dimension variables
    Dim objCDOSYSCon
    'Create the e-mail server object
    Set objCDOSYSMail = Server.CreateObject("CDO.Message")
    Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
    'Set and update fields properties
    With objCDOSYSCon
    'Outgoing SMTP server
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTPSERVER"
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'CDO Port
    .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'Timeout
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Fields.Update
    End With
    'Update the CDOSYS Configuration
    Set objCDOSYSMail.Configuration = objCDOSYSCon
    'Set and update email properties
    With objCDOSYSMail
    '0=Low, 1=Normal, 2=High
    .Fields("urn:schemas:httpmail:importance").Value = 1
    'Who the e-mail is from
    .From = Request.Form("email_address")
    'Who the e-mail is sent to
    .To = "andrewrobstewart@gmail.com"
    'Who the e-mail is CC'd to
    .Cc = ""
    'The subject of the e-mail
    .Subject = Request.Form("email_subject")
    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
    .TextBody = Body
    .Fields.Update
    'Send the e-mail
    .Send
    End With
    'Close the server mail object
    Set objCDOSYSMail = Nothing
    Set objCDOSYSCon = Nothing
    'Rederect after sending email
    Response.Redirect Request.Form("redirect_to")
    %>

    </body>
    </html>


    is the number of fields incorrect? seemed simple enough, didn't make any changes other than adding my email.
     
    arstewar, Mar 22, 2009 IP
  6. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Your page language seems to be set to javascript (first line):
    
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    
    Code (markup):
    Yet your coding is visual basic. Maybe try changing the first line to:
    
    <%@LANGUAGE="VB" CODEPAGE="65001"%>
    
    Code (markup):
    I think thats it, i haven't used classic asp for a while.
     
    camjohnson95, Mar 23, 2009 IP
  7. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    or it maybe LANGUAGE="VBScript" ...
     
    camjohnson95, Mar 23, 2009 IP
  8. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @ camjohnson95

    I think it's VBScript from doing a search on it, though I tried both, VBScript got me somewhere.

    Almost all the way through, up to line 51.

    CDO.Message.1 error '80040213'

    The transport failed to connect to the server.

    /ohlandproperties/cdosys.asp, line 51



    'The subject of the e-mail
    .Subject = Request.Form("email_subject")
    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
    .TextBody = Body
    .Fields.Update
    'Send the e-mail
    .Send
    End With
    'Close the server mail object
    Set objCDOSYSMail = Nothing
    Set objCDOSYSCon = Nothing
    'Rederect after sending email
    Response.Redirect Request.Form("redirect_to")
    %>


    Also, in the ASP mail version I did not set the script, didn't have that first 7 lines of code like I do in the CSOSYS, could that be the source of problems there?

    Thanks so much by the way.
     
    arstewar, Mar 23, 2009 IP
  9. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #9
    in the following line:
    
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTPSERVER"
    
    Code (markup):
    have you changed = "SMTPSERVER" to the address of your smtp server? e.g: "mail.yourdomain.com"
     
    camjohnson95, Mar 23, 2009 IP
  10. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    @ camjohnson95

    put the right smtpserver in

    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "relay-hosting.secureserver.net"
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    'CDO Port
    .Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    'Timeout
    .Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    .Fields.Update


    new error is:

    error '8004020e'
    /ohlandproperties/cdosys.asp, line 51


    error is located in the same spot:

    'The subject of the e-mail
    .Subject = Request.Form("email_subject")
    'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
    .TextBody = Body
    .Fields.Update
    'Send the e-mail
    .Send
    End With
    'Close the server mail object
    Set objCDOSYSMail = Nothing
    Set objCDOSYSCon = Nothing
    'Rederect after sending email
    Response.Redirect Request.Form("redirect_to")
    %>



    I did a little research on that error and found this:

    • The script returns error '8004020e'

    Problem:

    The ASP script returns an error like:

    error '8004020e'
    myscript.asp, line xx

    and line xx is:

    objCDOSYSMail.Send

    Solution:

    This error is caused by the email component not being able to send the email. The possible causes of this error are:

    Access to the mail server thru the email component is denied. Make sure you supply a valid SMTP Server in the ASP Settings window.

    The SMTP Server requires a valid Login and Password to send the email. You must supply a correct value in the ASP Settings window.

    The field used in the From of the Email to form's owner doesn't contain a valid email address. Verify that you're validating the field value against a valid email address.

    Some mail servers do not allow sending email using a From email address with a domain name different than the one is configured in the web server. In this case, you should not use a field of the HTML form as the From. Instead, use a Generic email address with the same domain name as the hosted one.


    Any thoughts?

    Thanks again, seems like this will never work, seems like it is so simple too...
     
    arstewar, Mar 23, 2009 IP
  11. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    And the SMTP server I am using is valid, checked and double-checked.
     
    arstewar, Mar 23, 2009 IP
  12. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #12
    maybe the SMTP server you are using requires authentication.
     
    camjohnson95, Mar 23, 2009 IP
  13. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    no there is nothing else I need from them, do you know of a more reliable code? or something else I can use?
     
    arstewar, Mar 24, 2009 IP
  14. blowingideas

    blowingideas Peon

    Messages:
    642
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #14
    anyone who has aspsmartmail dll that works on windows server? apparently all that can be downloaded in the net doesn't work with windows server. they are only good for xp.
     
    blowingideas, Mar 26, 2009 IP
  15. arstewar

    arstewar Guest

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Meh, I had to go on craigslist and pay someone to help me out and explain all this, wasn't getting anywhere, he did some php code, explained it, and I switched my hosting to a linux server

    thanks for the help tho!
     
    arstewar, Mar 26, 2009 IP