ASP.NET - CDONTS mail -  Error:Cannot create ActiveX component.

Posted on 2005-04-06
Last Modified: 2013-11-25
Since I haven't worked with ASP.NET for over a year, I forgot what I did when my code worked. It is probably some setting, or whatever, but I cannot remember.

My problem is that on the line below (marked with '<<<') I have the error message "Cannot create ActiveX component."
I use WIndows XP with IIS 5 and the Microsoft Visual Basic .NET    (version 2003)
Any help is appreciated.


 Sub SendMail(ByVal strContent As String, ByVal strDate As String)

        Dim strSubject As String = "Review for - " & strDate
        Dim objSendMail = CreateObject("CDONTS.NewMail") '<<< it is here that the problem occurs
        Dim HTML As String
        'Dim objSendMail As New MailMessage   ' NEW

        Dim js As New JavaScript ' my class

        ' Set all the properties on the NewMail object
        objSendMail.From = conFrom '""
        objSendMail.To = EmailList()

        objSendMail.Importance = 1  '  0: faible 1=normale 2=haute
        objSendMail.BodyFormat = 0  '0
        objSendMail.MailFormat = 0  '0 - HTML; 1 - PlainText
        objSendMail.Subject = strSubject

        objSendMail.Body = strContent

            'Send the message
            'SmtpMail.Send(objSendMail) 'NEW
            js.MsgAlert(Me, "Sent.", "alert")
        Catch exc As Exception
            js.MsgAlert(Me, "Retry.", "alert")
            objSendMail = Nothing
        End Try

    End Sub
Question by:mjasic
    LVL 25

    Accepted Solution

    Windows XP do not ship with CDONTS.dll.  You can copy the CDONTS.dll from c:\winnt\system32 directory of a Windows 2000 PC and the use the regsvr32 CDONTS command to register it on XP box.

    Best, Nauman.
    LVL 9

    Expert Comment

    It's not classic asp...

    Use the built in Mail object in .NET - it's a lot easier.
    LVL 25

    Expert Comment

    I think the CDONTS library is needed with the Sytem.Web.Mail namespace.  Any updates?

    Thanks, Nauman.

    LVL 2

    Author Comment

    It worked.
    Thank a lot.

    LVL 2

    Author Comment

    My problem was that I changed a laptop one year ago (XP Pro instead of 2000 Pro) and after that, I never had the opportunity to test my old ASP.NET applications. I didn't know that CDONTS.dll no more exists on XP :(

    - CDONTS does not need System.Web.Mail namespace.
    - Why I don't use built-in mail object?  Because I have no idea what is the server IP or name. When I finish testing the application on my PC, I copy my site to a test server (does not have SMTP installed), and then the administrator copies the files to a production server.
    So, I really don't know what the name of the server is. And the code with Mail object never worked on my laptop (the same reason).

    Thanks for help.


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now