By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

HELP please - Automation error

P: 3
Hi everyone!

I am brand new to the Access world. I have downloaded files for a data base that I will use with my new job to my computer.

The data base tables and information is working great.

However, when I attempt to press the button that is suppose to open my outlook and import the emails - so that I can email the selelcted emails formt eh data base - I get a Run-time Error. I am so unfamiliar with programming - and I need some help!

Here is the error:
2147024770 (8007007e)
Automation error
The specified module could not be found.

I click on 'debug' and the following is what I see: (I made bold the line that is hilted yellow on my screen)

Expand|Select|Wrap|Line Numbers
  1. Public Sub CreateEmail(AllRecipients As Boolean, Optional EMail As String = "")
  2.    Dim rs As DAO.Recordset
  3.    Dim appOutLook 'As Outlook.Application
  4.    Dim objMAPINameSpace 'As NameSpace
  5.    Dim objMailItem 'As MailItem
  6.    Dim objRecipient 'As Recipient
  7.    Dim strSubject As String
  8.  
  9. Set appOutLook = CreateObject("Outlook.Application")
  10.  
  11.    If appOutLook = "Outlook" Then
  12.       strSubject = InputBox("Enter the subject of the e-mail", "Subject")
  13.       Set objMAPINameSpace = appOutLook.GetNamespace("MAPI")
  14.       objMAPINameSpace.Logon "profile", "password"
  15.       Set objMailItem = appOutLook.CreateItem(0)   'olMailItem=0
  16.       If AllRecipients Then
  17.          Set rs = CurrentDb.OpenRecordset("SearchResults", dbOpenForwardOnly)
  18.       Else
  19.          If EMail = "" Then
  20.             Set rs = CurrentDb.OpenRecordset("SELECT * FROM SearchResults WHERE SendTo = True", dbOpenForwardOnly)
  21.          Else
  22.             Set rs = CurrentDb.OpenRecordset("SELECT * FROM SearchResults WHERE False", dbOpenForwardOnly)
  23.          End If
  24.       End If
  25.       While Not rs.EOF
  26.          Set objRecipient = objMailItem.Recipients.Add(rs!Email1)
  27.          objRecipient.Type = 3   'olBCC=3
  28.          Set objRecipient = Nothing
  29.          rs.MoveNext
  30.       Wend
  31.       If EMail <> "" Then
  32.          Set objRecipient = objMailItem.Recipients.Add(EMail)
  33.          objRecipient.Type = 3   'olBCC=3
  34.          Set objRecipient = Nothing
  35.       End If
  36.       rs.Close
  37.       Set rs = Nothing
  38.       objMailItem.Subject = strSubject
  39.       objMailItem.Body = "Message body goes here"
  40.       objMailItem.Save
  41.       objMAPINameSpace.Logoff
  42.       Set objMAPINameSpace = Nothing
  43.       Set appOutLook = Nothing
  44.  
  45. '      MsgBox "Your e-mail message has now been prepared and saved in your draft messages." & vbCrLf & _
  46. '             "Please verify that the message is correct before sending it.", vbInformation, "Message Created"
  47.    Else
  48.       MsgBox "Error opening Outlook." & vbCrLf & _
  49.              "Please try again before verifying with Daniel.", vbInformation, "Outlook Error"
  50.    End If
  51. End Sub
Sep 25 '07 #1
Share this Question
Share on Google+
5 Replies


Scott Price
Expert 100+
P: 1,384
First of all, what version of Access and Outlook are you running?

Regards,
Scott
Sep 25 '07 #2

P: 3
I am using access 2003 and outlook 2003. (sorry - should have thought to say that in the original post)
Sep 25 '07 #3

Scott Price
Expert 100+
P: 1,384
I am using access 2003 and outlook 2003. (sorry - should have thought to say that in the original post)
OK, there are two things that come to mind... The most satisfactory resolution will come from the first, less satisfactory from the second.

When you open the database, press Alt+F11. This will bring up the VBA code window. Go to the Tools menu and click on References (first item on the list). Scroll the menu until you find Microsoft Office 12.0 Object Library and click the check box. (Note there will also be a Microsoft Access 11.0 Object Library, that is not the same as the Office library).

Try your email again.

Post back here if this doesn't work and we'll try the second.

Regards,
Scott
Sep 26 '07 #4

P: 3
I found the item in the list - and checked the box.

(it was version 11 instead of 12).

Then I tried the email button again - and I still get the same errror message.

So we will have to try option #2

Sherri
Sep 26 '07 #5

Scott Price
Expert 100+
P: 1,384
I found the item in the list - and checked the box.

(it was version 11 instead of 12).

Then I tried the email button again - and I still get the same errror message.

So we will have to try option #2

Sherri
For Office 2003 it should be version 12, check again to make sure that you have the Office and not Access object library. Also, have you installed all the MS Office updates? As an added suggestion, go to their website and see what updates they suggest (not just Windows updates, but Office updates as well.)

Regards,
Scott
Sep 26 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.