PDA

View Full Version : Accessing Outlook from Access - Error 8007007e



Michael 514
06-02-2006, 03:35 PM
Hello again everyone!

I've done some research on this topic, but I cannot seem to come up with a better answer than uninstalling Office 2003, and then re-installing it.

Perhaps someone has an idea that can help me. I would appreciate it very much!

The problem only happens on some machines...

When this line is encountered:

Set appOutLook = CreateObject("Outlook.Application")

...on some PCs, we receive the following error:

Run-time error '-2147024770 (8007007e)':
Automation Error
The specified module could not be found.

Lovely.

I don't know any VBA... I'm a huge noob... but if you have any workarounds, I can sure type over the guy's work!

I hope one of you guys can help!

Thanks,

Mike






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

OBP
06-03-2006, 04:29 AM
For outlook this is overkill. What does the rest of the code do?
Does it construct an email?
Send an email with an attachment?
I can provide you with code that should work OK provided that the Access user has Outlook open at the time.

boneKrusher
06-03-2006, 06:05 AM
Is the MS Outlook 11 object library turned on?

Michael 514
06-03-2006, 12:48 PM
Hi guys,

Thanks for the responses!

Believe it not, overnight, the user decided to completely uninstall Office 2003, and then reinstall it. It worked.

Regarding turning on the MS Outlook 11 object library... that's very interesting! I didn't even think of that. On my PC, it's turned on.

I have another user who is having the same problem. Before I ask her to uninstall and re-install Office 2003, I am going to ask her to check for the object library. That will be interesting!

OBP, I am going to paste the entire e-mail module here. It actually prompts the user for a Subject line, and then saves it to drafts.

There was something in our wishlist that we wanted to implement. I bet you, or one of you guys can do it relatively easily! Instead of prompting the user to type the text to put in the Subject field, we really wanted to allow the user to be able to pick her text from a combo box, or drop down, and allow her to choose the subject line she wants! I figured I would make a table with an autonumber primary key, and then a text field with the text. That would be neat if one of you guys can help.

If you can, please let me know...!

I think I should create a new thread, though, and leave this thread to focus only on the 8007007e error. (I don't want to hog my own thread!)

Boy, would my team appreciate that being able to select from pre-determined subject fields!

I will keep you posted if the Object Library is a factor in the 8007007e error.

Here is the module in its entirety:

Option Compare Database
Option Explicit
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

Norie
06-03-2006, 12:51 PM
Michael

The reference shouldn't be what is causing the error because you are using late binding and don't actually need it.

OBP
06-04-2006, 02:16 AM
Michael, I will private mail you about your other requirements, rather than you having to start a new Thread.