Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002
    Location
    London
    Posts
    73

    Unanswered: Sending Emails via Access on Outlook 2000 and Outlook 2002

    Hi I have a problem with my Outlook referencing in VBA in Access 2000.

    On one machine I use Access 2000 and Outlook 2000. This machine I can send emails via Access and its fine.

    But on another machine, which uses Access 2000 and Outlook 2002, it does not like it.

    I have gone under reference and under the first machine its ticked against Microsoft Outlook 9.0 Object Library and the file it uses is MSOUTL9.OLB

    On the other machine, which uses Outlook 2002, it uses Microsoft Outlook 10. Object Library MSOUTL.OLB.

    In the Outlook 2002 machine I get an error message on my code. Tried copying the reference MSOUTL9.OLB but it could not find it under available references, Is there a way it can use my code on this machine or it can use the MSOUTL9.OLB reference.

    Thank you in advance

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    most robust solution is to late-bind Outlook (...zero reference to OL required).

    here is some not-particularly-brilliant demo code that might point you in the late-bind direction. you do NOT need **any** reference to Outlook.

    Code:
    Option Compare Database
    Option Explicit
    
    ''  ##################### CONDITIONS OF USE #####################
    ''  Module izyMailer
    ''  Copyright(C)izyrider, 2004
    ''  Late-binding Outlook mailer
    ''  This module and underlying code may be freely modified and
    ''  included in any application including commercial applications
    ''  provided that these conditions of use are left unchanged.
    ''  You may NOT charge any fee for distributing this code as a
    ''  stand-alone object.
    ''  In line with the general spirit of open-source software, you
    ''  may wish to inform the author of any improvement you develop.
    ''  Contact "izyrider" via private mail at www.dbforums.com/f84
    ''  ################### END CONDITIONS OF USE ###################
    
    'constants for izyMailer
    Global Const izymailer_Draft = 1
    Global Const izymailer_Display = 2
    Global Const izymailer_Send = 3
    Const imCstOLMailItem = 0
    
    Public Function izyMailer(isMode As Integer, isTo As String, isSubj As String, isBody As String, Optional isFile As String = "NONE") As Boolean
        'REQUIRES:
        '   isMode = izymailer_Draft, izymailer_Display, or izymailer_Send
        '   isTo    the recipient's mail address
        '   isSubj  the mail subject
        '   isBody  the mail body text
        'OPTIONALLY ACCEPTS
        '   isFile  the drive:/path/name.extension of a file to attach
        'RETURNS
        '   on error FALSE, else TRUE
        
        On Error GoTo err_izyMailer
        
        Dim objOutlook As Object
        Dim objOutMail As Object
        Dim objOutFile As Object
        
        Set objOutlook = CreateObject("Outlook.Application")
        Set objOutMail = objOutlook.CreateItem(imCstOLMailItem)
        Set objOutFile = objOutMail.Attachments
        
        With objOutMail
            .Subject = isSubj
            .Body = isBody
            .To = isTo
        End With
           
        If Not isFile = "NONE" Then
            Set objOutFile = objOutMail.Attachments
            objOutFile.Add isFile
        End If
        
        If isMode = izymailer_Display Then
            objOutMail.Display
        Else
            objOutMail.Save                                         'save as draft
            If isMode = izymailer_Send Then objOutMail.Send         'and possibly send
        End If
        
        izyMailer = True                                            'success return
        
    exit_izyMailer:
        On Error Resume Next
        Set objOutFile = Nothing
        Set objOutMail = Nothing
        Set objOutlook = Nothing
        
        Exit Function                               'and exit
    
    err_izyMailer:
        izyMailer = False                           'failure return
        MsgBox Err.Description, vbCritical, "izyMailer Error"
        Resume exit_izyMailer
    
    End Function
    ignore the nay-sayers who claim late-bind is slow: offer a free ice-cream to the first five users who spot the half-dozen extra milliseconds compared with early-bind

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •