Chapter 6. An Email Client Application

A generic email client application provides familiar ground for learning about MAPI’s capabilities. Today’s email clients have rich feature sets that exercise every corner of MAPI. It’s enjoyable and educational to duplicate such functionality in an email client application of one’s own. That’s what this chapter and Chapter 7, are about, and the lessons learned along the way apply to a broad array of messaging applications.

This chapter teaches you the basics of using Collaboration Data Objects (CDO) to send and receive messages that include plain and formatted text, file attachments, and embedded objects. Chapter 7 discusses more advanced message handling techniques.

The Sample Application

The sample code for Messenger 2000, a Visual Basic/CDO email client application, can be found in \VBMsg\Samples\Chapter6\Messenger\ (if you installed the samples to their default location). See Appendix F, for more information. The sample demonstrates the features described in this chapter. Figure 6-1 shows Messenger 2000’s main screen.

Messenger 2000, a sample CDO application

Figure 6-1. Messenger 2000, a sample CDO application

The code is divided into seven modules:

Globals (Globals.bas)

This standard module contains helper functions, the declaration of the single Session object used throughout the program, and the application’s Sub Main.

frmMain (frmMain.frm)

This form module presents an Explorer-style ...

Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.