O'Reilly logo

Access™ 2007 VBA Programmer's Reference by Armen Stein, Geoffrey Griffith, Rob Cooper, Teresa Hennig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.2. Working with Outlook

In today's high-tech world, one of the most common forms of communication is e-mail. Allowing users to send e-mail messages via your application that contains customized data provides a powerful feature to any database application. Access 2007 makes it extremely easy and inexpensive to implement this functionality, using just a few lines of VBA code

Open the sample database and click the Material Order Form button. The Frame Material Order Form opens. Assume that the current record shown in this form contains important information that the user needs to communicate via an e-mail. Click the Alert button and the new e-mail is created. Notice that the e-mail contains the order number, the original order due date, expected material receipt date, and the required Action information that is contained in the current record in the form. Although this message is fairly simple, it is extremely easy to continue customizing the data to your preference, or better yet, let the user do it herself to add a personal touch.

The programmatic creation of e-mails, as found in the Material Orders form in the sample database, is made possible by the Outlook Object Model. To write the VBA code to export the data from Access to Outlook, open the Frame Material Order Form in Design mode and view the code behind the Click event of the Alert button. In working with the Outlook Object Model, you must set a reference to the Microsoft Outlook 12.0 Object Model option in the References ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required