Thanks Ron, I did the first and it worked. I didn't understand at
first, but persevered!
Regards Shaun
Ron de Bruin wrote:
You must add a reference to Outlook in the VBA editor or use Late binding
Start here
http://www.rondebruin.nl/sendmail.htm
--
Regards Ron de Bruin
http://www.rondebruin.nl
"manxshaun" wrote in message oups.com...
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