SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Coal Valley IL
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CDO Form Email HELP!

    I have always used cdonts when coding form emails and now have to code using cdosys with a remote server. The server where I host has given me the following to work with as a starter:

    Code ASP:
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message")
    'This section provides the configuration information for the remote SMTP server.
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
    ' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
     
    ObjSendMail.Configuration.Fields.Update
     
    'End remote SMTP server configuration section==
     
    ObjSendMail.To = "someone@someone.net"
    ObjSendMail.Subject = "this is the subject"
    ObjSendMail.From = "someone@someone.net"
     
    ' we are sending a text email.. simply switch the comments around to send an html email instead
    'ObjSendMail.HTMLBody = "this is the body"
    ObjSendMail.TextBody = "this is the body"
     
    ObjSendMail.Send
     
    Set ObjSendMail = Nothing


    But I have no idea what to do with it. I've played around and have come up with the following but am currently getting this error: CDO.Message.1 error '8004020d'

    At least one of the From or Sender fields is required, and neither was found.

    /ContactUs.asp, line 32

    There may be more than one issue with my entire code and I'm hoping for help with this soon - I really need to get this done by tomorrow and have been all over the internet. Here is my entire page code:

    Code ASP:
    <%@LANGUAGE="VBSCRIPT"%>
     
    <% 
    visitorname = Request("visitorname")
    msgBody = Request("msgBody")
     
    Set ObjSendMail = CreateObject("CDO.Message")
     
    'This section provides the configuration information for the remote SMTP server. 
     
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.votive.org"
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
    ' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password. 
    'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication 
    'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="info@votive.com" 
    'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="mypassword" 
     
    ObjSendMail.Configuration.Fields.Update 
     
    'End remote SMTP server configuration section== 
    ObjSendMail.To = "seala@mchsi.com"
    ObjSendMail.Subject = "Comments-Questions From Website"
    ObjSendMail.From = Request("emailfrom")
     
     
    ObjSendMail.TextBody= msgBody
    ObjSendMail.Send
     
     
    Set ObjSendMail = Nothing
    Response.Redirect "thanks.asp"
    %> 
    <html><head>
    <title>Website</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" width="80%"><tr><td>
     
    <form id="ContactForm"method="post" action="sendmail.asp"><br>
    Your name: <input type="text" name="visitorname" size="20"><br>
    Your e-mail: <input type="text" name="emailfrom" size="40"><br>
    <center>Questions or Comments</center><br>
    <textarea cols="40" rows="6" name="msgBody"></textarea><br><br>
     
    <input type="submit" value="Send Email"><br>
    </form>  
     
    <script type="text/javascript">
    document.ContactForm.visitorname.focus();
    </script>
     
    </td></tr></table>
    </center>
     
    </body>
    </html>

    Really need help right away - Thanks so much!!!!
    Last edited by Mittineague; Nov 27, 2010 at 18:13. Reason: reformatting bbcode tags

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    verify that the from address exists

    Code ASP:
    response.write "emailfrom= " & Request.form("emailfrom")


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •