Outlook Error Codes

Fix Outlook Error 287 at MailItem.Send in Access VBA

Nimra MalikNimra Malik Nov 27, 2026 869 views

Question details

Identify why an Access VBA routine hangs or raises error 287 when sending HTML email through Outlook after an Office upgrade.

Fix Outlook Error 287 at MailItem.Send in Access VBA
Product
Microsoft Access 2013 and Microsoft Outlook
Device & OS
not provided
Scenario
An Access database uses Outlook automation to create and send HTML email after an upgrade from Access 2007 to Access 2013.
Observed behavior
The routine may hang or raise error 287 at MailItem.Send. An invalid procedure call or argument error can also occur at the BodyFormat assignment.
Before you start

Open the database in Access and locate the VBA procedure that creates and sends the Outlook MailItem. Confirm that Outlook is installed, configured with a mail profile, and can send a test message manually.

Solution 1Recommended

Check Outlook VBA constants and the HTML message setup

Use this approach when the routine uses late binding or fails at the BodyFormat assignment.

Late binding does not make Outlook's named constants available automatically. The numeric value for olFormatHTML is 2; defining it explicitly avoids relying on an Outlook library reference for that constant.

Check the complete procedure for other Outlook constants and properties, and confirm they are supported by the Office version in use.

1
Open the VBA procedure

In Access, press Alt+F11 to open the VBA editor, then find the procedure that creates the Outlook message.

2
Define the HTML format constant

If the code uses late binding, add `Const olFormatHTML As Long = 2` in the procedure before the constant is used. Alternatively, assign `2` directly to BodyFormat.

3
Review message creation

Check that the code creates a mail item with `CreateItem(0)`, sets `.BodyFormat = olFormatHTML`, and assigns the HTML content to `.HTMLBody`. Verify that the BodyFormat assignment is made on the mail item.

4
Test before sending

Temporarily replace `.Send` with `.Display`, run the procedure, and inspect the recipient and formatted message in Outlook. Then restore `.Send` and test it with a recipient you control.

Check Outlook VBA constants and the HTML message setup
If BodyFormat still fails: Check the exact error and the object receiving the assignment. Explicitly defining the constant addresses an undefined or incorrect constant; it does not resolve every possible property or security error.
Free Microsoft Office alternative

Work with Office documents in WPS Office

WPS Office is a free, lightweight alternative with a familiar interface and support for common Microsoft Office formats, making it easier to move everyday document work. It does not fix Outlook's MailItem.Send error or replace the Access database automation.

Edit documents related to your email workflow in one office suiteOpen and save common Microsoft Word, Excel, and PowerPoint formatsUse a familiar interface for everyday office tasksMove compatible documents to a lightweight, free suite
microsoft office alternative - wps office

Frequently Asked Questions

Why is olFormatHTML not recognized in my Access VBA code?

With late binding, Outlook's named constants are not automatically available. Declare `Const olFormatHTML As Long = 2` in the procedure, or use `2` in the BodyFormat assignment.

How can I inspect the email without sending it?

Temporarily replace the MailItem's `.Send` call with `.Display`. Run the Access procedure and inspect the resulting message in Outlook before restoring `.Send`.

Where can I check Outlook's programmatic access settings?

In Outlook, go to File > Options > Trust Center > Trust Center Settings > Programmatic Access, if the option is available. Some settings may be controlled by your organization's administrator.

Does defining olFormatHTML fix error 287 at Send?

Not necessarily. Defining the constant can fix a late-binding issue in the HTML format setup, but an error at Send may have another cause. Step through the code and check for Outlook prompts and the exact error description.