Building a Mail-Enabled Application

About this chapter

This chapter describes how to use the messaging application program interface (MAPI) with PowerBuilder applications to send and receive electronic mail.

About MAPI

PowerBuilder supports MAPI (messaging application program interface), so you can enable your applications to send and receive messages using any MAPI-compliant electronic mail system.

For example, your PowerBuilder applications can:

  • Send mail with the results of an analysis performed in the application

  • Send mail when a particular action is taken by the user

  • Send mail requesting information

  • Receive mail containing information needed by the application's user

Both Extended MAPI and Simple MAPI are supported, with the exactly same set of mail objects, properties, functions and events, except for very few difference. By default, Extended MAPI is used, but if the Windows operating system being used does not support Extended MAPI, PowerBuilder will use the legacy Simple MAPI.

To use Simple MAPI in PowerBuilder 2017 and later:

In the PowerBuilder IDE, add the following to the [PB] section of your pb.ini that PB uses for initialization.

[PB]
UseSimpleMAPI=yes

Default location of pb.ini is C:\Users\[username]\AppData\Local\Appeon\PowerBuilder [version].

For a deployed application, create a text file named pb.ini with the text above and deploy it with your application executable.

64-bit PowerBuilder mail applications can only work with 64-bit Windows MAPI. 32-bit PowerBuilder applications can only work with 32-bit Windows MAPI.

How MAPI support is implemented

To support MAPI, PowerBuilder provides the items listed in the following table.

Item

Name

A mail-related system object

MailSession

Mail-related structures

MailFileDescription

MailMessage

MailRecipient

Object-level functions for the MailSession object

MailAddress

MailDeleteMessage

MailGetMessages

MailHandle

MailLogoff

MailLogon

MailReadMessage

MailRecipientDetails

MailResolveRecipient

MailSaveMessage

MailSend

Enumerated datatypes

MailFileType

MailLogonOption

MailReadOption

MailRecipientType

MailReturnCode


Using MAPI

To use MAPI, you create a MailSession object, then use the MailSession functions to manage it.

For example:

MailSession PBmail
PBmail = CREATE MailSession
 
PBmail.MailLogon(...)
... // Manage the session: send messages,
... // receive messages, and so on.
PBmail.MailLogoff()
 
DESTROY PBmail

You can use the Browser to get details about the attributes and functions of the MailSession system object, the attributes of the mail-related structures, and the valid values of the mail-related enumerated datatypes.

For information about using the Browser, see the section called “Browsing the class hierarchy” in Users Guide. For complete information about the MailSession object functions, see the section called “mailSession object” in Objects and Controls. For complete information about MAPI, see the documentation for your MAPI-compliant mail application.