• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

Outlook 12 Object Library Compatibility with Office 2003

I have an Access Database I have been working on in Office 2007.  One component is the capability to email a report which required the Outlook 12 Object Libarry to work with the Outlook.Application function in VB.

When I tested the database on Office 2003 which many users still have, the Outlook 12 Object Library fails and causes all sorts of errors.  This is the only place I'm having a problem with reverse compatibility and hope someone has an idea of how to resolve.
0
ClearYourSix
Asked:
ClearYourSix
  • 7
  • 7
  • 3
1 Solution
 
tbsgadiCommented:
Hi ClearYourSix,

When working with 2003 change to the Outlook 11 Object Library


Good Luck!

Gary
0
 
Patrick MatthewsCommented:
Hello ClearYourSix,

When I automate one Office app from another, I *always* use late binding, which usually papers over these
differences.

If you post your code we Experts can give more specific guidance.  Late binding, in a nutshell:

1) You do not set references to the external library
2) Instead of strongly typing the outside object variables, you declare them as type Object
3) You use CreateObject to instantiate the outside Application, and then use that application variable
as the "root" to tap into the external object model

Regards,

Patrick
0
 
ClearYourSixAuthor Commented:
There are over 500 users.  So, the solution I need is something that involves no intervention.  When I look at VB References, I don't have the choice to select Object 11 in addition to Object 12.  See code below.  

When I deleted the reference to Outlook 12, the email capability quit working.  It only works when i have explicitly selected it in the VB Reference Library.  Code is below that originally worked with the Object Library.  
On Error GoTo Err_EMAILIndividual_Click
 
strEmailTo = Forms![Agency Business Plan]![Email_Alias]
strDate = Forms![Agency Business Plan]![Report_Date]
 
DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview
DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
   With objOutlookMsg
   ' Add the To recipient(s) to the message. Substitute
   ' your names here.
   Set objOutlookRecip = .Recipients.Add(strEmailTo)
   objOutlookRecip.Type = olTo
   ' Set the Subject, Body, and Importance of the message.
   .Subject = "RESULTS: Business Plan Report - " & strDate
   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf
   .Sensitivity = olPrivate
   ' Add attachments to the message.
   If Not IsMissing(AttachmentPath) Then
   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")
   End If
   ' Resolve each Recipient's name.
   For Each objOutlookRecip In .Recipients
         If Not objOutlookRecip.Resolve Then
         objOutlookMsg.Display
         End If
         Next
   .Send
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
   
Kill ("c:\temp\business plan report.snp")
DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo
DoCmd.Maximize
Forms("Agency Business Plan").SetFocus
   
 
Exit_EMAILIndividual_Click:
    Exit Sub
Err_EMAILIndividual_Click:
    MsgBox Err.Description
      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo
    DoCmd.Maximize
    Forms("Agency Business Plan").SetFocus
   
   End Sub

Open in new window

0
Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

 
tbsgadiCommented:
You can add the 2003 Object to your PC from somebody that has 2003
0
 
ClearYourSixAuthor Commented:
tbsgadi:  

How do I get it from them?  The database was originally developed in 2003 and when I switched to 2007, it automatically wiped out the Outlook 11 reference and replaced it with Outlook 12.
0
 
tbsgadiCommented:
You're just copying the tlb/dll file to your PC
0
 
ClearYourSixAuthor Commented:
when I do that and pull it in, where it carry then to office 2003 users or at least stay active?  if so and office 2007 is later installed, will they need to reinstall tool so Outlook 12 is picked up?
0
 
tbsgadiCommented:
If you have the 2003 library it upgrades to 2007 - not the other way around
0
 
ClearYourSixAuthor Commented:
I think I can make that work.  How do I ADD a reference to the library that doesn't show up in the list already?
0
 
tbsgadiCommented:
You press the browse button & go to the msoutl.olb file
0
 
ClearYourSixAuthor Commented:
OK, give me a few hours to track down that file and test it.  Thanks.  Will get back to you tbsagdi.
0
 
tbsgadiCommented:
Good Luck!
0
 
Patrick MatthewsCommented:
Converting to late binding, so that you need *no references* to Outlook...
On Error GoTo Err_EMAILIndividual_Click
 
strEmailTo = Forms![Agency Business Plan]![Email_Alias]
strDate = Forms![Agency Business Plan]![Report_Date]
 
DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview
DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient
Dim objOutlookAttach As Object 'Outlook.Attachment
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(0)  'olMailItem
   With objOutlookMsg
   ' Add the To recipient(s) to the message. Substitute
   ' your names here.
   Set objOutlookRecip = .Recipients.Add(strEmailTo)
   objOutlookRecip.Type = 1   'olTo
   ' Set the Subject, Body, and Importance of the message.
   .Subject = "RESULTS: Business Plan Report - " & strDate
   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf
   .Sensitivity = 2   'olPrivate
   ' Add attachments to the message.
   If Not IsMissing(AttachmentPath) Then
   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")
   End If
   ' Resolve each Recipient's name.
   For Each objOutlookRecip In .Recipients
         If Not objOutlookRecip.Resolve Then
         objOutlookMsg.Display
         End If
         Next
   .Send
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
   
Kill ("c:\temp\business plan report.snp")
DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo
DoCmd.Maximize
Forms("Agency Business Plan").SetFocus
   
 
Exit_EMAILIndividual_Click:
    Exit Sub
Err_EMAILIndividual_Click:
    MsgBox Err.Description
      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo
    DoCmd.Maximize
    Forms("Agency Business Plan").SetFocus
   
   End Sub

Open in new window

0
 
ClearYourSixAuthor Commented:
tbsgadi... got the Outlook 11 file but was unable to get it to override Outlook 12 Object.  Now trying matthew's code....
0
 
tbsgadiCommented:
You need to first untick the outlook l2 object & then browse to the 11
0
 
ClearYourSixAuthor Commented:
THANK YOU for editing the code.  I had just started to research what you meant by late-binding.  The code works beautifully.
0
 
Patrick MatthewsCommented:
ClearYourSix,

Glad to help :)

Regards,

Patrick
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 7
  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now