library not registered error when calling email from access

L

Liz O'Donoghue

Calling the following code from VBA:
appOutlook.createItem(olMailItem)

Results in:
Error #: 2147319779; automation error. Library not registered

Steps taken:
uninstalled and reinstalled outlook and access

Code runs great on two machines, but not the third, which has the
following software/os Versions:
Windows XP Professional v 5.1 2600_sp_qft (service pack 2)
access 2003 build 11.8166.8202 sp3
outlook 2003 build 11.8217.8202 sp3

Here is a snippet of code I'm trying to run:

strBCC = Left(strBCC, Len(strBCC) - 1)
'Create new mail message and send to contacts
Set msg = appOutlook.CreateItem(olMailItem)
With msg
.To = strTo
.Subject = strSubject
.Body = strBody
.BCC = strBCC
.Display
If Len(Trim(Me.attachLoc)) > 0 Then
.Attachments.Add Me.attachLoc.Value
End If
End With


Anyone seen anything like this? Anyone have any suggestions of how i
might proceed?

Thanks,

Liz
 
C

Chris O''Neill

Hmmm... I wonder if using late binding to the Outlook Library might fix it?
Maybe give this a try:

'******** Start Code ********
Dim objOutlook As Object
Dim objOutlookMsg As Object

strBCC = Left(strBCC, Len(strBCC) - 1)

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
.To = strTo
.Subject = strSubject
.Body = strBody
.BCC = strBCC
.Display
If Len(Trim(Me.attachLoc)) > 0 Then
.Attachments.Add Me.attachLoc.Value
End If
End With

'Clean Up
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
'******** End Code **********

Good luck with your quest!

Regards, Chris
 
T

Tony Toews [MVP]

Liz O'Donoghue said:
Code runs great on two machines, but not the third, which has the
following software/os Versions:

I'm with Chris. First thing I'd try is going to late binding. Late
binding means you can safely remove the reference and only have an
error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

This also is very useful when you don't know version of the external
application will reside on the target system. Or if your organization
is in the middle of moving from one version to another.

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top