Chapter 11. E-mail

Because the mail never stops. Every day it keeps coming in, and the faster it goes out, the faster it comes in. And the stacks grow higher and higher. And then the bar code reader breaks, and it's Publisher's Clearing House day!

?Newman, Seinfeld

In the last several years, nothing has changed the way that companies do business and people communicate more than e-mail and the World Wide Web. The capability to send electronic mail instantaneously from one place to another has quietly integrated itself into everyday life. Combine e-mail with a Personal Digital Assistant such as a Pocket PC device, and your applications can provide your users with a popular and pervasive way to communicate with others (for example, your scheduling application can e-mail status reports).

As you have already seen in previous chapters, Pocket PC provides a variety of ways to have its software talk over a wired or wireless Internet connection. Back in Chapter 1, you learned how to use the socket interface, or Winsock, to develop applications that use TCP/IP to enable two devices to communicate with each other. Although you could certainly use sockets to write an e-mail application, developing a mail application from the ground up is not only time-consuming, it can also be extremely proprietary in the way it stores messages. Fortunately, Pocket PC already provides a robust set of programming libraries for working with all aspects of e-mail.

It is recommended that any application that will interact with electronic mail on a Pocket PC device use the built-in Mail API, or MAPI. The MAPI library provides developers with several COM objects that are used to handle a variety of e-mail protocols, as well as a standard way to work with message attachments and the storage of e-mail messages. In addition, by using MAPI, you will be working with a centralized message store. This not only enables your application to leverage mail transports and message storage that other developers have built, but gives other applications access to a mail transport that you have written or to messages that you have placed in the message store.

Every standard Pocket PC device includes the Inbox application (see Figure 11.1) for sending and receiving messages.

Figure 11.1. Pocket Inbox


To use the Mail API (as well as the COM e-mail interfaces that are supported on Pocket PC) within your application, you need to include the cemapi.h header file, and link with the cemapi.lib library.