Solved

Outlook 12 Object Library Compatibility with Office 2003

Posted on 2009-03-31
17
695 Views
Last Modified: 2013-11-25
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
Comment
Question by:ClearYourSix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 3
17 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24028959
Hi ClearYourSix,

When working with 2003 change to the Outlook 11 Object Library


Good Luck!

Gary
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24028963
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
 

Author Comment

by:ClearYourSix
ID: 24029020
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029044
You can add the 2003 Object to your PC from somebody that has 2003
0
 

Author Comment

by:ClearYourSix
ID: 24029071
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
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029086
You're just copying the tlb/dll file to your PC
0
 

Author Comment

by:ClearYourSix
ID: 24029131
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
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029160
If you have the 2003 library it upgrades to 2007 - not the other way around
0
 

Author Comment

by:ClearYourSix
ID: 24029176
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
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029195
You press the browse button & go to the msoutl.olb file
0
 

Author Comment

by:ClearYourSix
ID: 24029216
OK, give me a few hours to track down that file and test it.  Thanks.  Will get back to you tbsagdi.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029222
Good Luck!
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24029484
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
 

Author Comment

by:ClearYourSix
ID: 24029508
tbsgadi... got the Outlook 11 file but was unable to get it to override Outlook 12 Object.  Now trying matthew's code....
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029528
You need to first untick the outlook l2 object & then browse to the 11
0
 

Author Closing Comment

by:ClearYourSix
ID: 31564829
THANK YOU for editing the code.  I had just started to research what you meant by late-binding.  The code works beautifully.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24030219
ClearYourSix,

Glad to help :)

Regards,

Patrick
0

Featured Post

Windows running painfully slow? Try these tips..

Stay away from Speed Up Computer Programs that do more harm than good.
Try these tips instead.
Step by step instructions in trouble shooting Windows Performance issues.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question