VBA & Macro Problems

Fix Access VBA Error: User-Defined Type Not Defined When Sending Outlook Email

Tauseeq MagsiTauseeq Magsi Nov 13, 2026 870 views

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.

Fix Access VBA Error: User-Defined Type Not Defined When Sending Outlook Email
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.
Before you start

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.

Solution 1Recommended

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".

1
Open the VBA editor

In Microsoft Access, press Alt+F11 to open the Visual Basic Editor.

2
Open the References dialog

Click Tools in the menu bar, then select References.

3
Add the Outlook object library

Scroll to Microsoft Outlook xx.x Object Library, check the box next to it, and click OK.

4
Compile the VBA project

Click Debug in the menu bar, then select Compile VBAProject or your database's project name to confirm the Outlook types are now recognized.

5
Test the email code safely

Run your code with .Display instead of .Send while testing, and verify the attachment path exists before the Send action.

Enable the Microsoft Outlook Object Library in Access VBA
Reference added: Enabling the correct reference resolves the "User-defined type not defined" error for Outlook.Application and Outlook.MailItem in early-bound Access VBA projects.
Free Microsoft Office alternative

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.

Free access to Writer, Spreadsheet, and Presentation for daily file editingOpens and saves Microsoft Word, Excel, and PowerPoint formats including DOCX, XLSX, and PPTXFamiliar ribbon interface and compatible file workflows ease migration from Microsoft OfficeLightweight design keeps document tasks simple when Access or Outlook automation is not required
QA img-9

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.