Chapter 12: Working with Outlook


Since Office 97, Outlook has been the Office component that handles email, tasks, contacts, appointments, and a few extras—the rarely used journal and yellow notes. Unless you’re using a non-Office product for these purposes, you probably use Outlook to handle your email and calendar (appointments), and perhaps tasks as well. However, if you use Access to store contact information, you need a way to get information from an Access table of contacts into Outlook so that you can send email messages to your contacts. If you enter contact data in Outlook (for example, storing an email address from an incoming message as a contact), you also need a way to get contact information from Outlook into an Access table.

Apart from dealing with contacts, there are also circumstances when you need to move Outlook data into Access tables and export data from Access tables to various sorts of Outlook items. This chapter will deal with writing Automation code for exporting Access data to Outlook and importing Outlook data into Access. The sample database for this chapter is Outlook Data Exchange.mdb, an Access 2000 database that can also be used in higher versions of Access. There is also a supplementary Outlook Data Exchange with Redemption.mdb database, illustrating use of Dmitry Streblechenko’s Redemption Library to avoid the annoying Object Model Guardian pop-up when working with mail messages and contacts in VBA code.

Writing Automation Code

To work with Outlook folders and items in VBA code, you need to write Automation code. See Chapter 11, Working with Word, for an explanation of Automation. Any Access database that works with Outlook needs a reference to the Outlook object model, which is set in the References dialog, opened from the Tools menu in the Visual Basic window, as shown in Figure 12.1.

click to expand
Figure 12.1

As explained in Chapter 11, the Outlook reference will be upgraded when a database is opened in a higher version of Office, but will not be downgraded when the database is opened in a lower version. This can be a problem with an Access 2000 database that is opened in both Access 2000 and Access 2002 or 2003. To prevent problems, set a reference to the Outlook 9.0 (2000) object model while the database is open in Access 2002 or 2003. See the References section in Chapter 11, for more details on this technique.

To save time when working with references and VBA code in general, see the “Some Handy Toolbar Buttons” section in Chapter 11, which shows you how to put buttons on your toolbar to quickly open the Visual Basic window and the References dialog.




Expert One-on-One(c) Microsoft Access Application Development
Expert One-on-One Microsoft Access Application Development
ISBN: 0764559044
EAN: 2147483647
Year: 2006
Pages: 124
Authors: Helen Feddema

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net