Freigeben über


Sending E-mail

Windows Mobile SupportedWindows Embedded CE Not Supported

8/28/2008

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 Mobile 6 SDK\Samples\Common\CPP\Win32\SendMail

    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.

Development Environments

SDK: Windows Mobile 6 Professional SDK and Windows Mobile 6 Standard SDK

Development Environment: Visual Studio 2005.

ActiveSync: Version 4.5.

See Also

Concepts

Code Samples for Windows Mobile
MAPI Rules
Set Message Store Properties
New Messaging Transport
New Message Class