troubleshooting Question

Getting Missing: Microsoft Outlook 14.0 Library on user's machine

Avatar of Juan Velasquez
Juan VelasquezFlag for United States of America asked on
Outlook
3 Comments1 Solution1756 ViewsLast Modified:
Hello,

I am getting the following reference error when a user is trying to send a email from Excel via automation.  The problem is that I am used late binding in writing the email code.  So why am I still getting that error

Getting Missing: Microsoft Outlook 14.0 Library on user's machine

How
' Module     : basSendMail
' Description:
' Procedures : SendMail(strRecipients As String, strCC As String, strBCC As String, strSubject As String, strTextBody As String, strHTMLBody As String, strAttachments As String, Optional eOlImportance As Integer = 1, Optional fDisplay As Boolean = True) As Boolean
' Modified   :
' 08/16/13 JV Cleaned with Total Visual CodeTools
'
' --------------------------------------------------
Option Explicit

Public Function SendMail(strRecipients As String, strCC As String, strBCC As String, strSubject As String, strTextBody As String, strHTMLBody As String, strAttachments As String, Optional eOlImportance As Integer = 1, Optional fDisplay As Boolean = True) As Boolean
    ' Comments: Sends a message using the following properties : Recipients, CC, BCC, SubjectBody, Delimiter
    ' Params  : strRecipients       List of recipients (TO address)
    '           strCC               List of carbon copy (CC) recipients
    '           strBCC              List of blind carbon copy (BCC) recipients
    '           strSubject          Subject of email
    '           strTextBody         Text Body of email, if any
    '           strHTMLBody         HTML body of email, if any
    '           strAttachments      List of attachment files (separated with the delimiter character which defaults to ;)
    '           eOIImportance       Importance of the email (defaults to olImportanceNormal, can also be olImportanceHigh, olImportanceLow)
    '           fDisplay            True to display the Mail Dialog, False otherwise. Default value is False.
    ' Returns : True if sent, False if failed
    ' Source  : Total Visual SourceBook
    
    On Error GoTo PROC_ERR
    
    Dim astrTmpAttachments() As String
    Dim intCount As Integer
    Dim strM_strDelimiter As String
    Dim objOOutlook As Object
    Dim objOutMailItem As Object
    Dim objOutAttachments As Object
    
    strM_strDelimiter = ","
    
    Set objOOutlook = CreateObject("Outlook.Application")
    ' Assume failure
    SendMail = False
    
    ' Create new instance of Outlook MailItem Object for you to work with.
    Set objOutMailItem = objOOutlook.CreateItem(0)          'You must use 0 instead of olMailItem with late-binding
    
    With objOutMailItem
        .To = strRecipients
        .CC = strCC
        .BCC = strBCC
        .Subject = strSubject
        .Body = strTextBody
        If strHTMLBody <> "" Then
            .HTMLBody = strHTMLBody
            .BodyFormat = 2   'olFormatHTML
        Else
            .BodyFormat = 1   'olFormatPlain
        End If
        .Importance = eOlImportance
        
        ' Parse Attachments and Add them to the Attachments Collection
        If strAttachments <> "" Then
            Set objOutAttachments = .Attachments
            astrTmpAttachments = Split(strAttachments, strM_strDelimiter)
            For intCount = 0 To UBound(astrTmpAttachments)
                objOutAttachments.Add astrTmpAttachments(intCount), 1  'olByValue
            Next intCount
        End If
        If fDisplay Then
            .Display
        End If
        
        .Send
        
    End With
    
    SendMail = True
    
PROC_EXIT:
    Exit Function
    
PROC_ERR:
    MsgBox "Error: " & Err.Number & ". " & Err.Description, , "COutlookMail.SendMail"
    Resume PROC_EXIT
End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros