YZlat
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.FromDisplayNam e = vFromName
objSendMail.Recipient = vTo
objSendMail.RecipientDispl ayName = 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
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.FromDisplayNam
objSendMail.Recipient = vTo
objSendMail.RecipientDispl
objSendMail.ReplyToAddress
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
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.
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
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.MailMessag e()
m.From = "YOU@YOURSITE.com"
m.To = "HIM@somwhere.com"
m.Body = txtEmailBody.Text
m.Subject = cboEmailTrackingNumber.Tex t
Try
System.Web.Mail.SmtpMail.S mtpServer = "mail.YOURSITE.com"
System.Web.Mail.SmtpMail.S end(m)
Catch ex As Exception
Success = False
Err = ex.Message
End Try
AW
here is a code snippet that uses VB.NET:
Dim m As New System.Web.Mail.MailMessag
m.From = "YOU@YOURSITE.com"
m.To = "HIM@somwhere.com"
m.Body = txtEmailBody.Text
m.Subject = cboEmailTrackingNumber.Tex
Try
System.Web.Mail.SmtpMail.S
System.Web.Mail.SmtpMail.S
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
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!
??? your code at the top is showing CDONTS! I am talking about vbSendMail!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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