Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Err Msg: Compiler Error - User-defined type not defined

Status
Not open for further replies.

rfhall3

Programmer
Feb 7, 2003
28
US
Version: Access 97

I am trying to implement an e-mail module into my Access DB. I have followed all the samples from various sites, but I am still missing something. When I run the code shown below, I receive the message:

Compiler Error: User-defined type not defined.

The error lined indicated is:
Dim objOutlook As Outlook.Application

I think I am missing an include, special module, etc., but I can't figure it out. The really frustrating part is that I have done it before in other projects, but now I am stumped. I would appreciate any help you can give.

My test code is listed below. Thanks in advance.

Bob Hall [americanflag]
rfhall50@cox.net

Code:
Option Compare Database
Option Explicit
Sub GettingFrustrated()

'******begin code******
Dim email, ref, origin, destination, notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem

'**gathers information from your form.  this sets the string variable to your fields
email = "rfhall50@cox.net"
ref = "Testing"
notes = "Just running a test."

'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)

'***creates and sends email
With objEmail
    .To = email
    .Subject = ref
    .Body = notes
    .Send
End With

'**closes outlook
Set objEmail = Nothing
objOutlook.Quit

End Sub

 
Hi rfhall3,

You need to add a reference to Microsoft Outlook x.x Object Library (under Tools > References).

Enjoy,
Tony
 
did you set a reference to the Microsoft Office Library?, if not, open a module in Design Mode, Select Tools, References, and then locate Microsoft Office 8.0 Object Library and click on the checkbox next to it.. you may not have 8.0 that is for Access 97, you might have a different version.


PaulF
 
Thank you both very much. My problem is now a non-problem and what little sanity I had before has been restored.

Again, Thank You.

Bobby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top