CDONTS error


im trying to send mail using CDONTS from my W2K server.
The code below actually sends the message, however an error is thrown.

  Method 'Send' of object 'INewMail' failed

so im not exactly sure what the deal is.

thanks - bg

Dim mobjMailer As CDONTS.NewMail

Set mobjMailer = New CDONTS.NewMail
mobjMailer.Send "", ", _
            "fake subject", "fake body"
Who is Participating?
Dave_GreeneConnect With a Mentor Commented:
I think it's because you are not defining a body format.

See this example

    Set oMail = CreateObject("CDONTS.NewMail")
    With oMail
       .From = ""
       .Subject = "Password Request"
       .To = Email
       .BodyFormat = 1
       .MailFormat = 1
       .Body = "Here is your password to access the JD Lowry Member Pages" & vbcrlf & Session("Password")
    End With  
    Set oMail = Nothing
try this instead of early binding maybe?

Dim mobjMailer As Object

Set mobjMailer = CreateObject("CDONTS.NewMail")
mobjMailer.Send "", "", "fake subject", "fake body"

hope this helps!
if you just want to get rid of the error, add

On Error Resume Next

before Dim mObjMailer...

hope this helps!
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

BeerGodAuthor Commented:
yea, the late bind doesnt help. im not sure if i want to skip over these errors, but if i have to i guess i will.
BeerGodAuthor Commented:
prolly, shouldnt always trust my books.
i got it working another way.

Set mobjSession = New CDONTS.Session
        mobjSession.LogonSMTP "SomeGuy", ""
        Set mobjOutBox = mobjSession.Outbox
        Set mobjMsg = mobjOutBox.Messages.Add
        mobjMsg.Subject = "Subject"
        mobjMsg.Text = msMsg
mobjMsg.Recipients.Add "You", ""
glad you got it working!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.