Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Getting Excel to send message via Outlook 2000

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Getting Excel to send message via Outlook 2000

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to send a single page email from excel 2000 using outlook xp vols2812 Excel Worksheet Functions 1 December 30th 06 06:45 PM
send a outlook template message from excel [email protected] Excel Programming 1 July 9th 05 03:42 AM
Send to Outlook 2000 not Outlook Express Jimbo Excel Discussion (Misc queries) 2 January 4th 05 08:19 PM
Send a range in Excel as the body of an Outlook Express message Katie[_3_] Excel Programming 2 August 14th 04 12:50 PM
Send current Excel File as an attachment using Outlook 2000 ZABU Excel Programming 3 May 28th 04 04:50 AM


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"