Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to send a single page email from excel 2000 using outlook xp | Excel Worksheet Functions | |||
send a outlook template message from excel | Excel Programming | |||
Send to Outlook 2000 not Outlook Express | Excel Discussion (Misc queries) | |||
Send a range in Excel as the body of an Outlook Express message | Excel Programming | |||
Send current Excel File as an attachment using Outlook 2000 | Excel Programming |