Sending E-mail

Send Feedback

This code sample is named SendMail. It demonstrates how to programmatically send e-mail messages using the Messaging APIs (MAPI). The application sends an e-mail message, per account, to a list of recipients. It stores one message per each account on the mobile device (POP3, ActiveSync, etc), in the account's Outbox.

Feature Area

Relevant APIs

Basic program flow

  1. Logs onto the message store.
  2. Gets the message store's table.
  3. For each local account:
    1. Opens the current store entry.
    2. Gets the Drafts folder (necessary for outgoing mail).
    3. Creates a new message in this folder.
    4. Sets relevant message properties (Recipients, Subject, Body, etc).
    5. Creates a file attachment.
    6. Sends the message.
    7. Cleans up.

Usage

To run the code sample

  1. Navigate to the solution file (*.sln), and double-click it. By default, the solution files are copied to the following folders:

    C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SDK\Samples\CPP\Win32\Sendmail\``SendMail.sln

    C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Smartphone SDK\Samples\CPP\Win32\Sendmail\``SendMail.sln

    Microsoft Visual Studio 2005 launches and loads the solution.

  2. Build the solution (Ctrl+Shift+B).

  3. Deploy the solution (F5).

To use the application

  • After running the application, check your Outbox or Sent Items folder. Depending on your network or partnership access, you will see your message(s).

Remarks

The application has no user interface, and requires no interaction.

The Recipient List, Subject, and Message Body, are specified in code, and can be changed.

Requirements

Pocket PC SDK: Windows Mobile 5.0 Pocket PC SDK.
Smartphone SDK: Windows Mobile 5.0 Smartphone SDK.
Development Environment: Visual Studio 2005.
ActiveSync: Version 4.0.

See Also

Code Samples | MAPI Rules | Set Message Store Properties | New Messaging Transport | New Message Class

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.