Getting Excel to send message via Outlook 2000

M

manxshaun

The following code produces the error "Compile error user-defined type
not defined". I didn't write this and am a beginner, so am struggling
to see why. It seems to be stopping at "Dim objOutlook As
Outlook.Application".

Public Function olk_SendMail(sTo As String, sSubject As String,
sMessage As String)

'-- use MS Outlook object to send mail
On Error GoTo Err_Trap
Dim objOutlook As Outlook.Application
Dim objMailItem As Outlook.MailItem
Set objOutlook = New Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)

With objMailItem
.To = sTo
.Subject = sSubject
.Body = sMessage
.Send
End With
Set objMailItem = Nothing
Set objOutlook = Nothing
Exit Function
Err_Trap:

ErrorCatch "MOD_MAIL.olk_SendMail()"

End Function

Regards manxshaun
 
M

manxshaun

Thanks Ron, I did the first and it worked. I didn't understand at
first, but persevered!

Regards Shaun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top