A beginner question: Send Mail in ASP using CDONTS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Prasad

    A beginner question: Send Mail in ASP using CDONTS

    Hi all,

    I had to write a page in ASP which sends an email. I googled and was
    able to write the following code:

    <html>
    <body>
    <%
    Set Mail = Server.CreateOb ject("CDONTS.Ne wMail")
    Mail.To = "XXXXXXXXXXXX@X XXXXX.COM"
    Mail.From = "YYYYYYYYY@YYYY Y.COM"
    Mail.Subject = "Test MAIL Subject"
    Mail.Body = " Body Body Body Body Body Bodyody Body Body"
    If Mail.Send Then
    Response.Write( "Mail has been sent successfully")
    Else
    Response.Write( "Mail Sending Failed")
    End If
    Set Mail = nothing
    %>
    </body>
    </html>

    When I run this script on a shared hosting server, It's saying "Mail
    Sending Failed". I had never written ASP code before and couldn't find
    what the reason is.. I also checked whether CDONTS.NewMail component
    is available.

    Please help me out..

    Thanks in advance,
    Prasad.

  • =?Utf-8?B?T2xkIFBlZGFudA==?=

    #2
    RE: A beginner question: Send Mail in ASP using CDONTS

    Your host may not allow CDONTS. Microsoft stopped shipping CDONTS as a
    standard part of the Windows Server a few years back. You host *CAN* add it,
    but may have chosen not to.

    It's possible that your host supports only CDOSYS, for example. And it's
    even possible that you host doesn't support *any* MS email component and uses
    one from a third party.

    You should contact your host for the proper component to use. Hopefully,
    your how will have a sample page in their FAQs.

    If you can't get help from your host, then it might be time to change hosts.

    "Prasad" wrote:
    Hi all,
    >
    I had to write a page in ASP which sends an email. I googled and was
    able to write the following code:
    >
    <html>
    <body>
    <%
    Set Mail = Server.CreateOb ject("CDONTS.Ne wMail")
    Mail.To = "XXXXXXXXXXXX@X XXXXX.COM"
    Mail.From = "YYYYYYYYY@YYYY Y.COM"
    Mail.Subject = "Test MAIL Subject"
    Mail.Body = " Body Body Body Body Body Bodyody Body Body"
    If Mail.Send Then
    Response.Write( "Mail has been sent successfully")
    Else
    Response.Write( "Mail Sending Failed")
    End If
    Set Mail = nothing
    %>
    </body>
    </html>
    >
    When I run this script on a shared hosting server, It's saying "Mail
    Sending Failed". I had never written ASP code before and couldn't find
    what the reason is.. I also checked whether CDONTS.NewMail component
    is available.
    >
    Please help me out..
    >
    Thanks in advance,
    Prasad.
    >
    >

    Comment

    • Anthony Jones

      #3
      Re: A beginner question: Send Mail in ASP using CDONTS


      "Prasad" <prasadk14@gmai l.comwrote in message
      news:fdb5b5f4-531c-4cd3-abf2-deab1530f808@w8 g2000prd.google groups.com...
      Hi all,
      >
      I had to write a page in ASP which sends an email. I googled and was
      able to write the following code:
      >
      <html>
      <body>
      <%
      Set Mail = Server.CreateOb ject("CDONTS.Ne wMail")
      Mail.To = "XXXXXXXXXXXX@X XXXXX.COM"
      Mail.From = "YYYYYYYYY@YYYY Y.COM"
      Mail.Subject = "Test MAIL Subject"
      Mail.Body = " Body Body Body Body Body Bodyody Body Body"
      If Mail.Send Then
      Response.Write( "Mail has been sent successfully")
      Else
      Response.Write( "Mail Sending Failed")
      End If
      Set Mail = nothing
      %>
      </body>
      </html>
      >
      When I run this script on a shared hosting server, It's saying "Mail
      Sending Failed". I had never written ASP code before and couldn't find
      what the reason is.. I also checked whether CDONTS.NewMail component
      is available.
      >
      Here is some example code to send email using CDOSYS:-

      Const cdoSendUsingMet hod =
      "http://schemas.microso ft.com/cdo/configuration/sendusing"
      Const cdoSMTPServer =
      "http://schemas.microso ft.com/cdo/configuration/smtpserver"
      Const cdoSMTPServerPi ckupDirectory =
      "http://schemas.microso ft.com/cdo/configuration/smtpserverpicku pdirectory"
      Const cdoSMTPServerPo rt =
      "http://schemas.microso ft.com/cdo/configuration/smtpserverport"

      Const cdoSendUsingPic kup = 1
      Const cdoSendUsingPor t = 2

      Dim oMsg : Set oMsg = CreateObject("C DO.Message")
      Dim oConfig : Set oConfig = CreateObject("C DO.Configuratio n")

      With oConfig.Fields
      .Item(cdoSendUs ingMethod) = cdoSendUsingPor t
      .Item(cdoSMTPSe rver) = "mysmtp.myserve r.com"
      .Item(cdoSMTPSe rverPort) = 25
      .Update
      End With

      oMsg.From = "Me <me@mymail.myse rver.com>"
      oMsg.To = "Bloke <bloke@somewere .com>"
      oMsg.Subject = "Test"
      oMsg.HTMLBody = "<html><body>He llo World</body></html>"
      Set oMsg.Configurat ion = oConfig


      oMsg.Send

      --
      Anthony Jones - MVP ASP/ASP.NET


      Comment

      • Prasad

        #4
        Re: A beginner question: Send Mail in ASP using CDONTS

        On May 28, 11:06 pm, "Anthony Jones" <A...@yadayaday ada.comwrote:
        "Prasad" <prasad...@gmai l.comwrote in message
        >
        news:fdb5b5f4-531c-4cd3-abf2-deab1530f808@w8 g2000prd.google groups.com...
        >
        >
        >
        Hi all,
        >
        I had to write a page in ASP which sends an email. I googled and was
        able to write the following code:
        >
        <html>
        <body>
        <%
        Set Mail = Server.CreateOb ject("CDONTS.Ne wMail")
        Mail.To = "XXXXXXXXX...@X XXXXX.COM"
        Mail.From = "YYYYYY...@YYYY Y.COM"
        Mail.Subject = "Test MAIL Subject"
        Mail.Body = " Body Body Body Body Body Bodyody Body Body"
        If Mail.Send Then
        Response.Write( "Mail has been sent successfully")
        Else
        Response.Write( "Mail Sending Failed")
        End If
        Set Mail = nothing
        %>
        </body>
        </html>
        >
        When I run this script on a shared hosting server, It's saying "Mail
        Sending Failed". I had never written ASP code before and couldn't find
        what the reason is.. I also checked whether CDONTS.NewMail component
        is available.
        >
        Here is some example code to send email using CDOSYS:-
        >
        Const cdoSendUsingMet hod =
        "http://schemas.microso ft.com/cdo/configuration/sendusing"
        Const cdoSMTPServer =
        "http://schemas.microso ft.com/cdo/configuration/smtpserver"
        Const cdoSMTPServerPi ckupDirectory =
        "http://schemas.microso ft.com/cdo/configuration/smtpserverpicku pdirectory"
        Const cdoSMTPServerPo rt =
        "http://schemas.microso ft.com/cdo/configuration/smtpserverport"
        >
        Const cdoSendUsingPic kup = 1
        Const cdoSendUsingPor t = 2
        >
        Dim oMsg : Set oMsg = CreateObject("C DO.Message")
        Dim oConfig : Set oConfig = CreateObject("C DO.Configuratio n")
        >
        With oConfig.Fields
        .Item(cdoSendUs ingMethod) = cdoSendUsingPor t
        .Item(cdoSMTPSe rver) = "mysmtp.myserve r.com"
        .Item(cdoSMTPSe rverPort) = 25
        .Update
        End With
        >
        oMsg.From = "Me <m...@mymail.my server.com>"
        oMsg.To = "Bloke <bl...@somewere .com>"
        oMsg.Subject = "Test"
        oMsg.HTMLBody = "<html><body>He llo World</body></html>"
        Set oMsg.Configurat ion = oConfig
        >
        oMsg.Send
        >
        --
        Anthony Jones - MVP ASP/ASP.NET

        Hi..
        Thank you all for your replies.. I git it worked. The actual problem
        was with the "From Address", which should be of the same domain I have
        taken. :)

        Cheers,
        Prasad

        Comment

        Working...