Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 865
  • Last Modified:

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
0
iainmacleod
Asked:
iainmacleod
3 Solutions
 
MINDSUPERBCommented:
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
 
peter57rCommented:
Have you set a reference to the outlook 14 object library (assuming you ar using Outlook 2010 as well)?
0
 
Dale FyeCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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