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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using Cdonts to send several emails

    Hello,
    Im trying to use Cdonts to send email from a server hosted at godaddy.com.
    I am able to send one email, but when I try to send a second email, it doesnt work. Basically, when someone fills out the form, they give me their email address. After they submit the form, I want to send two emails: one to myself and one back to the person saying his email was received (using the email he provided). When I only send one email, it works fine. But when I add the code to send a second email, it doesnt work.

    The way Im trying to do it is by creating two mail objects and sending them separately. Is this a correct way to send two emails using the same asp file?

    Here is my asp code. (The html form code is basic so I didnt include it - you can assume the email given is valid)
    Any help would be great. thanks!

    Delfin

    ---------------------------------------
    <html>
    <body>

    <% dim email
    email=Request.Form("email")
    %>

    <%
    ' Create first mail object
    Dim MyMail
    Set MyMail = Server.CreateObject("CDONTS.NewMail")

    ' Set parameters
    If IsObject(MyMail) Then
    MyMail.From = "d_lazaro@hotmail.com"
    MyMail.To = "d_lazaro@hotmail.com"
    MyMail.Subject = "Testing mail script"
    MyMail.BodyFormat = 0
    MyMail.MailFormat = 1
    MyMail.Importance = 2
    MyMail.Body = "This is a test."
    MyMail.Send
    Set MyMail = Nothing
    Response.write("message sent")
    Else
    Response.write("message not sent")
    End If

    'The second mail object
    Dim AutoReply
    Set AutoReply = Server.CreateObject("CDONTS.NewMail")

    'Set parameters
    If IsObject(AutoReply) Then
    AutoReply.From = "d_lazaro@hotmail.com"
    AutoReply.To = email
    AutoReply.Subject = "Email Confirmation"
    AutoReply.BodyFormat = 0
    AutoReply.MailFormat = 1
    AutoReply.Importance = 2
    AutoReply.Body = "Your Email has been received. "
    AutoReply.Send
    Set AutoReply = Nothing
    Response.write("second message sent")
    Else
    Response.write("An error has occurred. Response not sent")
    End If
    %>
    Last edited by Delfin Lazaro; 07-23-2004 at 01:05 AM. Reason: remove irrelevant code

  • #2
    New to the CF scene
    Join Date
    Jul 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Nevermind, I figured it out.

    Just in case anyone wants to know, I had to use to recreate the same Mail object I created earlier, instead of declaring a new one.

  • #3
    New Coder
    Join Date
    Aug 2003
    Location
    Shawnee Mission, Kansas
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Solution

    I have a very simple solution, don't use CDONTS, its not even supported by Microsoft anymore:

    CDOSYS has replaced CDONTS, there is a great demo script on my site:

    Try X-Send v1.1.2 for Windows Server 2000 and XP Professional.
    http://www28.brinkster.com/freeasphelp/#Downloads
    John Shepard
    Beyond The Impossible
    -----------------------------
    http://freeasphelp.tech.nu/
    FreeASPHelp by John Shepard
    Sign Up for a free account today!
    100% Free ASPHelp

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Perhaps put code like this after the first e-mail:
    ' Destroy object.
    Set MyMail = Nothing

    And perhaps put code like this after the second e-mail:
    ' Destroy object.
    Set AutoReply = Nothing

    -Edit-

    Oops, sorry, I see that you already HAVE code like this after each e-mail.

    But if you do decide to try CDO here are changes I made to convert CDONTS stuff to be CDO stuff instead:

    o Change objCDONTS to be called objCDO (actually this is just a cosmetic change)

    o This:
    Set objCDONTS = Server.CreateObject("CDONTS.NewMail")

    Changed to this instead:
    Set objCDO = Server.CreateObject("CDO.Message")

    o This:
    objCDONTS.Body = strEmailBody

    Changed to this instead:
    objCDO.TextBody = strEmailBody

    o This removed:
    ' Importance.
    ' (0=Low, 1=Normal, 2=High)
    objCDONTS.Importance = 1

    And http://www.asp101.com/samples has some good e-mail examples such as the e-mail attachment example which uses the newer CDO (instead of the deprecated CDONTS which no longer ships with Windows).
    Last edited by Bullschmidt; 07-28-2004 at 06:58 AM.
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

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