View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
manxshaun manxshaun is offline
external usenet poster
 
Posts: 2
Default Getting Excel to send message via Outlook 2000

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