Error on Macro that Sends email through Outlook
Posted by Ben O. on May 04, 2001 2:49 PM
I've got a macro that sends a simple email message (it does not attach the Excel workbook) using Outlook. I used the macro on a previous spreasheet and it worked fine. Now I've copied the code to my new worksheet and it doesn't work. A keep getting a "User-defined type not defined" compile error. I can't remember where I got the code from, so I can't remember if there are any more steps I have to take. Here's the code. If anyone could help, I'll be grateful:
Private Sub Notify()
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
With objMail
.To = "beno@bsg.com"
.Subject = "Test"
.Body = "This is an automated message from Excel."
.Display
End With
Set objMail = Nothing
Set objOL = Nothing
End Sub