Sending Email to Outlook from Access 2010

I am trying to simply open an Outlook email from a button on a form.
I get this error:

Compile Error:
User-defined type not defined


   Dim CsDB As DAO.Database
   Dim rst As DAO.Recordset
   Dim appOutlook As Outlook.Application (this is the line that errors)
   Dim msg As Outlook.MailItem
   Dim strEmail As String

I am sure i have had this error before but cannot see why?

Thanks in advance
iainmacleodAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MINDSUPERBConnect With a Mentor Commented:
Try to check the DAO reference is activated in the Microsoft Visual Basic. Check for outlook as well.

Follow the below steps to do it:

1. Open the Visual Basic Program
2. Under Tools, Select Reference
3. Find DAO and check it

Sincerely,
Ed
0
 
peter57rConnect With a Mentor Commented:
Have you set a reference to the outlook 14 object library (assuming you ar using Outlook 2010 as well)?
0
 
Dale FyeConnect With a Mentor Commented:
If all you want to do is open a new email, why not use the sendobject method?

docmd.SendObject acSendNoObject,, , "someone@domain.com",,,"subject", "MessageText: exclude this if you just want to open it and write the message yourself", true

You will need to include an error handler in your code to handle the error that gets generated (2501, the SendObject action was canceled) when the user cancels the message, but this is easy enough to deal with.
0
All Courses

From novice to tech pro — start learning today.