OutlookEmailRoutines_bas
Main Topics
Browse All TopicsI am receiving the following error...
Err.number = -2147024770
Err.Description = Automation error
The specified module could not be found.
when trying to create an outlook object in my application.
The Declariation and Dim Statements seem fine
'-------------------------
Public Sub sbSendMessage(strTo As String, _
strSubj As String, _
strBody As String, _
Optional strCC As String, _
Optional strBCC As String, _
Optional strAttch As String)
On Error GoTo ErrorMsgs
Dim objOl As Outlook.Application
Dim objOlMsg As Outlook.MailItem
Dim objOlRecip As Outlook.Recipient
Dim objOlAttch As Outlook.Attachment
--------------------------
The error occurs when I try to create the session
'-------------------------
' Create the Outlook session.
'-------------------------
Set objOl = CreateObject("Outlook.Appl
I have check my references and have a reference to MS OL 11 Lib (msoutl.olb) file
I have checked Technet, MSDN and every book at my disposal. I have compared my code to at least 10 other routines from assorted sources.
I do not believe it is the code...
Anyone have a clue as to what may be causing the error?
Rich
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Similar error in this Q: http://www.experts-exchang
Does that help ?
Nic;o)
Nic;o)
I have all the latest SP's (as per MS Office Update)
When I type Outlook. in the immediate window I do get intellisense response
I am figuring it has to be something with the installation... but what??
When I get home I will try to do a repair on the Office Installation and hit Office Update again.
I ran the reg for the DAO360 dll as per the other questions suggestion... NFG
The application is running fine. This is a New addition to the app, and my first serious attempt at Automation, so it isn't necesserally a new problem that a restore point would help..
Outlook works fine...
Application works fine (save this new addition)
Nothing else is acting flakey... but it does not want to "Create the Object"
Now the reference to Outlook does not point to a DLL, but to msoutl.olb
What is an OLB??
Rich
Do you mind posting all of your code? There could be something that you haven't posted that is causing it to not work.
Here's an example from an existing db I use that works:
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim EmlSubject As String
Dim strAttach as String
StrAttach = "C:\Myfile.doc"
Set objOutlook = CreateObject("Outlook.appl
Set objEmail = objOutlook.CreateItem(olMa
EmlSubject = "Status Report"
With objEmail
.Subject = EmlSubject
.BodyFormat = olFormatHTML
.Attachments.Add StrAttach
.Display
End With
The full routine Follows...
Public Sub sbSendMessage(strTo As String, _
strSubj As String, _
strBody As String, _
Optional strCC As String, _
Optional strBCC As String, _
Optional strAttch As String)
On Error GoTo ErrorMsgs
Dim objOl As Outlook.Application
Dim objOlMsg As Outlook.MailItem
Dim objOlRecip As Outlook.Recipient
Dim objOlAttch As Outlook.Attachment
'-------------------------
' Create the Outlook session.
'-------------------------
Set objOl = CreateObject("Outlook.Appl
'-------------------------
' Create the message.
'-------------------------
Set objOlMsg = objOl.CreateItem(olMailIte
With objOlMsg
'-------------------------
' Add the To recipient(s) to the message. Substitute
' your names here.
'-------------------------
Set objOlRecip = .Recipients.Add(strTo)
objOlRecip.Type = olTo
'-------------------------
' Add the CC recipient(s) to the message.
'-------------------------
If Len(strBCC) Then
Set objOlRecip = .Recipients.Add(strCC)
objOlRecip.Type = olCC
End If
'-------------------------
' Add the CC recipient(s) to the message.
'-------------------------
If Len(strBCC) Then
Set objOlRecip = .Recipients.Add(strBCC)
objOlRecip.Type = olBCC
End If
'-------------------------
' Set the Subject, Body, and Importance of the message.
'-------------------------
.Subject = strSubj
.Body = strBody
.Importance = olImportanceHigh 'High importance
'-------------------------
' Add attachments to the message.
'-------------------------
If Not IsMissing(strAttch) Then
Set objOlAttch = .Attachments.Add(strAttch)
End If
'-------------------------
' Resolve each Recipient's name.
'-------------------------
For Each objOlRecip In .Recipients
If Not objOlRecip.Resolve Then
objOlMsg.Display
End If
Next
.Send
DoCmd.Beep
End With
Set objOlMsg = Nothing
Set objOl = Nothing
Set objOlRecip = Nothing
Set objOlAttch = Nothing
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. " & vbCrLf & _
"For more information, see the document at " & vbCrLf & _
"http://www.microsoft.com/
Else
MsgBox Err.Description, vbInformation, Err.Number
End If
End Sub
Thanks to everyone that attempted to help.
I could not get this piece of my app to work, so I have put it on the back burner.
I will attempt it again in the next week or so, (given the time) and will try it on a clean install of XP and Office 2k3.
If I still have problems... I'll post again!
Thanks again
Rich
Business Accounts
Answer for Membership
by: capricorn1Posted on 2006-02-17 at 13:15:41ID: 15984801
what is the name of the module where you place your function/sub.
the name of the module should be different from the name of function or sub.