Fix Outlook Error 287 at MailItem.Send in Access VBA
Question details
Identify why an Access VBA routine hangs or raises error 287 when sending HTML email through Outlook after an Office upgrade.

- 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.
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.
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.
In Access, press Alt+F11 to open the VBA editor, then find the procedure that creates the Outlook message.
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.
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.
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 security prompts and isolate the Send error
Use this approach if the message is created successfully but the procedure still hangs or fails at Send.
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.

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.




