Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

Run-time error '438' Object does not support this property or method

I have a DLL that gives me the following error: Run-time error '438' Object does not support this property or method.
here is my code:

Public Function SendEmail(vServer As Variant, vFrom As Variant, vFromName As Variant, vTo As Variant, vToName As Variant, vSubject, vFileName, vMsgBody)
    On Error GoTo errHandler
   
    'a reference to microsoft cdo for nts 1.2 library
    Dim objSendMail As CDONTS.NewMail
    Set objSendMail = New CDONTS.NewMail
    objSendMail.SMTPHost = vServer           <-----ERROR HERE
    objSendMail.From = vFrom
    objSendMail.FromDisplayName = vFromName
    objSendMail.Recipient = vTo
    objSendMail.RecipientDisplayName = vToName
    objSendMail.ReplyToAddress = vFrom
    objSendMail.Subject = vSubject
    objSendMail.Attachment = vFileName 'attached file name
    objSendMail.Message = vMsgBody
    objSendMail.Send
    Set objSendMail = Nothing
    SendEmail = 1
    Exit Function
errHandler:
    SendEmail = 0

End Function
Avatar of Arthur_Wood
Arthur_Wood
Flag of United States of America image

there is no .SMTPHost method or property on the CDONTS.NewMail object

in addition, most of the Properties that you appear to be using, are NOT valid on a CDONTS.NewMail object.

where did you get this code?

AW
If you tried to do a Run with Full Compile, this code would NOT compile.  The error you are getting is because you are relying on the Just-In-Time compiler, to compile the code, JUST before it is needed.

Avatar of YZlat

ASKER

so what do I put instead of objSendMail.SMTPHost ?
you need to use the Object model that is appropriate to the task you are trying to accomplish.  You cannot simply grab an clkass without knowing what it is intended to do.  What are you trying to accomplish, and why did you think the CDONTS.NewMail class was the right one to use?

If you are using the CDONTS.NewMail class, then look at the methods and properties that THAT class supports, and use those.

AW
do you have .NET?  

here is a code snippet that uses VB.NET:

        Dim m As New System.Web.Mail.MailMessage()
     
        m.From = "YOU@YOURSITE.com"
        m.To = "HIM@somwhere.com"
        m.Body = txtEmailBody.Text
        m.Subject = cboEmailTrackingNumber.Text

        Try
            System.Web.Mail.SmtpMail.SmtpServer = "mail.YOURSITE.com"
            System.Web.Mail.SmtpMail.Send(m)
        Catch ex As Exception
            Success = False
            Err = ex.Message
        End Try

AW
Better use the free vbSendMail component: http://www.freevbcode.com/ShowCode.Asp?ID=109
Avatar of YZlat

ASKER

emoreau, that's exactly what I have
>>emoreau, that's exactly what I have


??? your code at the top is showing CDONTS! I am talking about vbSendMail!
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial