MAPI Messaging Subsystem

Using the MAPI OCX Controls

In this exercise, you will use ActiveX controls to create a mail-enabled application in Visual Basic. The ActiveX controls used in this exercise interface with MAPI.

* To set up a Microsoft Mail Postoffice

  1. From the Control Panel, double-click Microsoft Mail Postoffice .
  2. Select Create a new Workgroup Postoffice and click Next .
  3. In the Postoffice Location box, type c:\ and click Next .
  4. You should be presented with the default, c:\wgpo0000 folder. Click Next .
  5. Enter the following Administrator information:
    Box Type (all lower case)
    Name admin
    Mailbox admin
    Password password

    The remaining boxes can be left blank. Click OK .

  6. A directory share notification will appear. Click OK .
  7. From the Windows 95 desktop, right-click Inbox and click Properties .
  8. Click Add and select only Microsoft Mail , then click Next .
  9. The c:\wgpo0000 folder should appear by default. Click Next .
  10. Be sure admin is selected and click Next .
  11. In the password box, type password and click Next .
  12. Click Next to accept the default address book file.
  13. Click Next to accept the default personal folder file.
  14. Leave, Do not add the Inbox to the Startup group selected and click Next .
  15. Click Finish .
* To open the Windows 95 Inbox
  1. Double-click the Inbox icon on the desktop.
  2. If you receive a prompt to enter a password, make sure the post office is set to "c:\wgpo0000", the mailbox is "admin." Type the word "password" into the password entry field, click OK .
  3. Minimize the Inbox .
* To use the MAPI controls in Visual Basic
  1. In Visual Basic, create a new Standard EXE .
  2. Right-click on the Toolbox and select Components.
  3. Select the Microsoft MAPI Controls 5.0 component and the Microsoft Rich Textbox Control 5.0
  4. Insert a MAPIMessages and MAPISession control on Form1 .
  5. Insert two textboxes, a rich textbox, and a command button on Form1 .
  6. Set the following properties:
    Control Property Value
    Text1 Name txtEmail
    Text2 Name txtSubject
    RichTextBox1 Name rtbMessage
    Command1 Name cmdSendMail
      Caption &Send Mail

  7. Your form should look like this:

  8. In the click event of cmdSendMail , type the following code:
     MAPISession1.SignOn With MAPIMessages1 .SessionID = Form1.MAPISession1.SessionID .Compose .MsgSubject = txtSubject.Text .MsgNoteText = rtbMessage.Text .RecipAddress = txtEmail.Text .AddressResolveUI = True .ResolveName .Send False End With MAPISession1.SignOff 
  9. From the Run menu in Visual Basic, select Start .
  10. Enter "admin" for the e-mail address.
  11. Enter a subject and message, then click Send Mail .

    The message will be sent to your post office account in Windows 95.

  12. Switch to the Inbox program to check for new mail.

    It may take a few seconds for the e-mail to arrive .

Lesson Summary

The Microsoft Messaging API makes information from MAPI-compliant messaging systems accessible to users across an organization. MAPI's open architecture allows services, such as fax, bulletin boards , and e-mail, to be used easily with any MAPI client application.

The MAPI front-end APIs are available in three parts . Simple MAPI and the Common Messaging Calls (CMC) support applications that require only basic messaging functions. Extended MAPI is used for creating advanced messaging-based applications.

MAPI provides the required API calls for messaging applications. These calls work with a second level of MAPI features called the messaging subsystem. The messaging subsystem responds to the API calls and performs the requested actions.

MAPI controls allow you to create messaging applications in Visual Basic. The MAPISession control signs on and establishes a MAPI session, and signs off from a MAPI session. The MAPIMessages control performs a variety of messaging system functions after a messaging session is established with the MAPISession control.



Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

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