Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1474
  • Last Modified:

Error 13 (type mismatch) when sending emails from access


I'm getting error 13 (type mismatch) when attempting to send emails from within Access 2003.

My code (which works for other clients) is:

Global OutlookApplication As Outlook.Application, OutlookMail As Outlook.MailItem, Inbox As Outlook.MAPIFolder, DetailSectionLeftDescriptionLabel As String

Set OutlookApplication = New Outlook.Application
Set OutlookMail = Outlook.Application.CreateItem(olMailItem)

I get error 13 with the last line.  The Client has Access 2003 and Office 2010 on a 32bit Win 7 PC.  The project has a reference for Microsoft  Outlook 14.0 Object Library added and I have tried moving it up the reference list as far as it can go.

Any help would be appreciated

  • 3
1 Solution
No obvious type mismatch issue jumping out at me, but try changing the last line to reference the outlook application object that your code created in the previous statement:

Set OutlookMail = OutlookApplication.CreateItem(olMailItem)

(I've dropped the 'dot' in Outlook.Application)
Also, just for kicks - If you don't have it already, place the following line at the top of this code module, right under Option CompareDatabase:

Option Explicit

Open in new window

Then compile your code, fixing any errors to ensure that all variables, Outlook constants, etc are recognized on your client's computer.
One more suggestion (involving a code change) - you can eliminate problems with product versions by using 'Late Binding'.  This involves declaring things as generic Objects instead of application specific types such as Outlook.Application, Outlook.MailItem, etc.

It's explained here:


The examples in the articles are Excel and Word automation, but the same principle applies to Outlook, Word or anything else.

Your code, using Late Binding would look something like this:

Global OutlookApplication As Object, OutlookMail As Object, Inbox As Object, DetailSectionLeftDescriptionLabel As String

Set OutlookApplication = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApplication.CreateItem(0)  '<-- replaced olMailItem with the actual value

Open in new window

WSITAuthor Commented:
I in the process of testing your ideas when I got a call to say they 'repaired' the Office installation and it then worked fine.  Why it would need repairing on all three PCs I couldn't tell you.  But thanks for the help.

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now