Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    CDO email not working

    Hello

    I am trying to collect information from an online form and to then send a copy of this information by email to the person who input it and to the Webmaster.

    This is what I have at the moment:

    <%
    Dim sFullNameTitle,sFullName,sEmailTitle,sEmailAddress,sBusinessTitle,sBusinessName,sCountryTitle,sCount ryName,MessageName,MessageTitle
    sFullNameTitle = "Fullname"
    sFullName = Request.Form("Fullname")
    sEmailTitle = "Email"
    sEmailAddress = Request.Form("Email")
    sBusinessTitle = "Business"
    sBusinessName = Request.Form("Business")
    sCountryTitle = "Country"
    sCountryName = Request.Form("Country")
    MessageName = "Message"
    MessageTitle = Request.Form("Message")

    Set myMail=CreateObject("CDO.Message")

    myMail.Subject="Your Submission"
    myMail.From="info@info.com"
    myMail.To="sEmailAddress"
    myMail.Cc="myAddress@yahoo.com"
    myMail.Bcc="myOtherAddress@hotmail.com"

    myMail.TextBody="Message" & vbcrlf & vbcrlf & _


    "Your copy. Please do not reply to this email" & vbcrlf & _

    "Full name: " & vbcrlf & _
    "Email: " & vbcrlf & _
    "Business: " & vbcrlf & _
    "Country: " & vbcrlf & _
    "Message: " & vbcrlf & _

    myMail.Send
    set myMail=nothing

    %>

    I am not getting any error messages, but neither does anyone receive any email messages.

    Maybe I should be using myMail.HTMLBody = "<HTML Code here>" instead of:

    myMail.TextBody="Message" & vbcrlf & vbcrlf & _

    Yet, this does not explain why the data input in the form fields (or the email addresses) are not being picked up.

    Any suggestions, please?

    Thanks.

    Steve

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Where's your mail server?

    If you don't have an SMTP server running on localhost that it can use as default*, then you're going to have to specify a mail server to use, and a method for passing emails to it.

    For example:

    Code:
    Set oMail =Server.CreateObject("CDO.Message")
    oMail.HTMLBody  = sMailBody
    oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2	' send using SMTP port. 1 = send using local pickup directory.
    oMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
    oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
    oMail.Configuration.Fields.Update
    oMail.Send
    set oMail=nothing
    *I'm not actually sure about this. My understanding was that you should ALWAYS specify a mailserver with CDO. That's the way I've always done it, anyhow.

    Either way, see this guide to sending mail with CDO. As you can see, depending on how your mail server is set up regarding authentication etc, there's actually quite a few fields you need to set in addition to the usual To, From, Subject etc.


  •  

    Posting Permissions

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