[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Declare CDONTS ActiveX object

Posted on 2004-08-25
6
Medium Priority
?
326 Views
Last Modified: 2013-12-25
I am trying to use CDONTS to send an email from my VB6 application. I am having trouble declaring the CDONTS.NewMail object. I do not wish to use Outlook for sending email, because I want this function to have no user intervention and if the Outlook PST file has a password on it the user is prompted, they are also warned that an email is being sent using Outlook without their consent. So please don't answer saying use Outlook.

So back to my problem, my question is, what is the correct method of declaring an ActiveX object, ie what is the correct statement, where in the program must / can it be placed etc.

I have used the following code I found on this site in a module that is called from the Form_Load event on the main form.

Public Sub SendMail()

            Dim objcdonts As New CDONTS.NewMail
            Set objcdonts = New CDONTS.NewMail
               
                objcdonts.From = "send.name@domain.com"
               
                objcdonts.To = "receive.name@anotherdomain.com"
               
                objcdonts.Bcc = ""
               
                objcdonts.Subject = "Subject Text"
               
                objcdonts.BodyFormat = 0
                objcdonts.MailFormat = 0
               
                '[1 -- > normal , 2 --> high ]
               
                objcdonts.Body = "Body Text"
               
                objcdonts.Send
             
             Set objcdonts = Nothing

End Sub

All lines of the code execute ok until the objcdonts.Send line, which fails with the run-time error 429, ActiveX component can't create object.

I have included Microsoft CDO for NTS 1.2 Library in Projects -> References.
I am using CDONTS.DLL version ver 6.0.3939.0 and registered it with regsvr32 cdonts.dll all ok.
I am developing this on Windows XP but need to implement it on Windows 2000 Server.

I have also tried using this code;

            Dim objcdonts As New CDONTS.NewMail
            Set objcdonts = CreateObject("CDONTS.NewMail")
            Set objcdonts = New CDONTS.NewMail

to declare the object, with the same result.

So I would like to know exactly how you should declare this object and where you should do it.

Thanks in advance.
0
Comment
Question by:DickCranium
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 11899186
See suggestion available on this open thread: http:Q_21106558.html
0
 

Author Comment

by:DickCranium
ID: 11899301
Thanks,

But none of the code suggested appears to work and I would still like to have the question answered, what is the correct statement to declare ActiveX object and where must it be placed.

Thanks
0
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 200 total points
ID: 11899470
Try:

Dim objcdonts As CDONTS.NewMail
Set objcdonts = CreateObject("CDONTS.NewMail")
...

or

Dim objcdonts As CDONTS.NewMail
Set objcdonts = New CDONTS.NewMail
...

or

Dim objcdonts As New CDONTS.NewMail
'No need Set objcdonts = xxx...
...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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