Fix Access VBA Error: User-Defined Type Not Defined When Sending Outlook Email
Question details
The user needs to fix an Access VBA compilation error that occurs when declaring Outlook.Application and Outlook.MailItem to send an external file as an Outlook email attachment from Microsoft 365 Access.

- Product
- Microsoft 365 Access and Outlook
- Device & OS
- not provided
- Scenario
- The user is writing Access VBA automation to create an Outlook email and attach an external file.
- Observed behavior
- VBA compilation fails with "User-defined type not defined" when the code uses early-bound Outlook.Application and Outlook.MailItem declarations.
Open the database in Microsoft Access, press Alt+F11 to open the Visual Basic Editor, and check whether Microsoft Outlook xx.x Object Library is already selected. Save a copy of the module if you plan to test both early-bound and late-bound versions.
Enable the Microsoft Outlook Object Library in Access VBA
Use this solution when you want early-bound Outlook objects, IntelliSense, and direct access to Outlook constants in your Access VBA project.
Early binding uses the Outlook object library so Access VBA can recognize Outlook.Application and Outlook.MailItem. If the reference is missing, the VBA compiler reports "User-defined type not defined".
In Microsoft Access, press Alt+F11 to open the Visual Basic Editor.
Click Tools in the menu bar, then select References.
Scroll to Microsoft Outlook xx.x Object Library, check the box next to it, and click OK.
Click Debug in the menu bar, then select Compile VBAProject or your database's project name to confirm the Outlook types are now recognized.
Run your code with .Display instead of .Send while testing, and verify the attachment path exists before the Send action.

Use late binding with Object variables and CreateObject in Access VBA
Use this solution to avoid version-specific Outlook references or when you cannot change project references in the VBA editor.
Use WPS Office as a Free, Lightweight Alternative to Microsoft Office
WPS Office does not host Microsoft Access VBA or Outlook automation, but it is a free, lightweight Office suite that opens and saves Word, Excel, and PowerPoint formats with a familiar ribbon interface, making it a practical alternative for everyday document work.

Frequently Asked Questions
Why does Access VBA show "User-defined type not defined" for Outlook.Application and Outlook.MailItem?
Because early binding requires the Microsoft Outlook Object Library. Open the VBA editor with Alt+F11, go to Tools > References, check Microsoft Outlook xx.x Object Library, and recompile the project.
Can I send an Outlook email from Access without enabling the Outlook object library?
Yes. Use late binding with Object variables and CreateObject("Outlook.Application"), then create the mail item with CreateItem(0) and add the attachment before displaying or sending.
Why does the attachment fail after adding the Outlook reference?
The path passed to Attachments.Add must exist and be spelled correctly. If the file path includes spaces or network locations, verify access and use .Display before .Send during testing.
Should I use .Display or .Send when testing Access Outlook email code?
Use .Display first so you can inspect the email and attachment before it actually sends. Switch to .Send only after the To, Subject, Body, and attachment are confirmed.
Does WPS Office support Microsoft Access VBA and Outlook email automation?
No. WPS Office is a free alternative for word processing, spreadsheets, and presentations, but it does not replace Access databases or Outlook email automation.




