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
- Public Sub CreateEmail(AllRecipients As Boolean, Optional EMail As String = "")
- Dim rs As DAO.Recordset
- Dim appOutLook 'As Outlook.Application
- Dim objMAPINameSpace 'As NameSpace
- Dim objMailItem 'As MailItem
- Dim objRecipient 'As Recipient
- Dim strSubject As String
- Set appOutLook = CreateObject("Outlook.Application")
- If appOutLook = "Outlook" Then
- strSubject = InputBox("Enter the subject of the e-mail", "Subject")
- Set objMAPINameSpace = appOutLook.GetNamespace("MAPI")
- objMAPINameSpace.Logon "profile", "password"
- Set objMailItem = appOutLook.CreateItem(0) 'olMailItem=0
- If AllRecipients Then
- Set rs = CurrentDb.OpenRecordset("SearchResults", dbOpenForwardOnly)
- Else
- If EMail = "" Then
- Set rs = CurrentDb.OpenRecordset("SELECT * FROM SearchResults WHERE SendTo = True", dbOpenForwardOnly)
- Else
- Set rs = CurrentDb.OpenRecordset("SELECT * FROM SearchResults WHERE False", dbOpenForwardOnly)
- End If
- End If
- While Not rs.EOF
- Set objRecipient = objMailItem.Recipients.Add(rs!Email1)
- objRecipient.Type = 3 'olBCC=3
- Set objRecipient = Nothing
- rs.MoveNext
- Wend
- If EMail <> "" Then
- Set objRecipient = objMailItem.Recipients.Add(EMail)
- objRecipient.Type = 3 'olBCC=3
- Set objRecipient = Nothing
- End If
- rs.Close
- Set rs = Nothing
- objMailItem.Subject = strSubject
- objMailItem.Body = "Message body goes here"
- objMailItem.Save
- objMAPINameSpace.Logoff
- Set objMAPINameSpace = Nothing
- Set appOutLook = Nothing
- ' MsgBox "Your e-mail message has now been prepared and saved in your draft messages." & vbCrLf & _
- ' "Please verify that the message is correct before sending it.", vbInformation, "Message Created"
- Else
- MsgBox "Error opening Outlook." & vbCrLf & _
- "Please try again before verifying with Daniel.", vbInformation, "Outlook Error"
- End If
- End Sub