« Previous Next »

Thread: Sending mail from classic ASP in IIS 7

Last post 07-07-2008 8:27 AM by Jonathan_W. 13 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (14 items)

Sort Posts:

  • 08-09-2007, 2:16 PM

    Sending mail from classic ASP in IIS 7

    Has anyone found out how to send mail from IIS 7 using classic ASP?

    Neither CDONTS or CDO appear to work and I cannot work out how to change the following .NET code into classic ASP

    objNewMail = New System.Net.Mail.MailMessage()
    objNewMail.From = New Net.Mail.MailAddress(strSenderFrom)
    objNewMail.To.Add(strRecipient)
    objNewMail.Subject = "the heading"

    objNewMail.Body = HTML
    objNewMail.IsBodyHtml = True

    Dim smtp As New Net.Mail.SmtpClient()
    smtp.Send(objNewMail)

  • 08-09-2007, 3:13 PM In reply to

    Re: Sending mail from classic ASP in IIS 7

    CDONTS won't work.  CDOSYS should work fine.  Here's a script I use for testing:

    <!--
        METADATA
        TYPE="typelib"
        UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" 
        NAME="CDO for Windows 2000 Library"
    --> 
    <% 
        Set cdoConfig = CreateObject("CDO.Configuration") 
     
        With cdoConfig.Fields 
            .Item(cdoSendUsingMethod) = cdoSendUsingPort 
            .Item(cdoSMTPServer) = "192.161.1.10" 
            .Update 
        End With
     
        Set cdoMessage = CreateObject("CDO.Message") 
     
        With cdoMessage
            Set .Configuration = cdoConfig
            .From = "
    myemail@sample.com"
            .To = "youremail
    @sample.com"
            .Subject = "Sample CDO Message"
            .TextBody = "This is a test for CDO.message"
            .Send
        End With
     
        Set cdoMessage = Nothing 
        Set cdoConfig = Nothing 
     
    Response.write "<HTML><head><title>A message has been sent.</title></head><body>A message has been sent.</body></HTML>"
     
    %>

    Replace  the .To and .From email addresses as appropriate.  Also chaneg the IP address of the SMTP server to yours.

    If this doesn't work, tell us how you know it doesn't work.  Just because the email didn't show up doesn't mean the code isn't working.  Check the SMTP logs, check for firewalls, authentication requirements, spam filters and so on.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 08-10-2007, 4:22 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    That almost works.  What I want to do is use localhost as the SMTP server (as this is working for ASP.NET) and I get the error :-

    "CDO.Message.1 error '80040213'

    The transport failed to connect to the server.

    /gdev/testemail.asp, line 99"

    have you got that working?

    P.S. It works OK if I specify an external SMTP server that I use with my ISP.

  • 08-10-2007, 5:10 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    Well, check if your server is able to talk to remote smtp host via port 25.

    Cheers,
    Bernard Cheah
  • 08-10-2007, 8:46 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    2 things :-

    1) I am trying to use locahost as the SMTP server, NOT a remote host

    2) telnet does not exist on a Vista machine, so how can I check whether the local host is listening on port 25?

  • 08-11-2007, 1:10 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    1) Ok, in this case do you have a local smtp running ? IIS 7 doesn't come with smtp. google this site - some previous posts have suggestion on where to get one.

    2) I think it's there. you just have to install it. Look at turn on /off windows feature - something like telnet client.

    Cheers,
    Bernard Cheah
  • 08-11-2007, 9:19 PM In reply to

    Re: Sending mail from classic ASP in IIS 7

    You happen to be using Vista? If so, the SMTP service doesn't come with Vista. If this is w2k8 server, make sure the smtp server is installed. This is available under the 'add feature' section. You can also install the telnet client. http://weblogs.asp.net/steveschofield/archive/2006/12/19/iis7-post-23-vista-and-smtp-server-where-is-it.aspx
    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 08-14-2007, 3:47 AM In reply to

    • GeorgeZ
    • Top 100 Contributor
    • Joined on 11-16-2006, 6:09 AM
    • Peking
    • Posts 67

    Re: Sending mail from classic ASP in IIS 7

    Mm...  Haven't used CDO with other SMTP server. I guess CDO is supporting other free SMTP Server. You can try them.

     

  • 08-14-2007, 4:28 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    It will support any standard SMTP server with authentication, etc.

    Cheers,
    Bernard Cheah
  • 07-05-2008, 5:15 PM In reply to

    Re: Sending mail from classic ASP in IIS 7

    I'm confused, CDONTS seems to work in my Windows 2008/IIS7 test environment.  Can anyone confirm? I'm just concered that it won't work when I go live. 

  • 07-07-2008, 12:29 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    cdonts was part of nt4/2000.  The dll wasn't included in w2k3 unless someone copied and registered it, same with w2k8.  I'd check to see if cdonts.dll is on the system.  I'd recommend going with asp.net system.web.mail or system.net.mail namespaces or use cdosys in classic asp. 

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 07-07-2008, 4:19 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

     Oh, I did copy it over to the Win2008 machine.  Is this completely bad practice? I'd rather not have to rewrite the ASP, since I am not a coder.

  • 07-07-2008, 7:18 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    That is perfectly fine copying the DLL over so you don't have to change any ASP code.

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 07-07-2008, 8:27 AM In reply to

    Re: Sending mail from classic ASP in IIS 7

    Fantastic! Thanks for your help.

Page 1 of 1 (14 items)
Microsoft Communities