Sending E-mail
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
- FreeProws function
- IMAPIFolder::CreateMessage function
- IMAPIProp::GetProps function
- IMAPISession::GetMsgStoresTable function
- IMAPISession::OpenMsgStore function
- IMAPITable::QueryRows function
- IMessage::SubmitMessage function
- IMsgStore::OpenEntry function
- MAPIFreeBuffer function
- MAPILogonEx function
- Messaging API (MAPI) API
- SRowSet function
Basic program flow
- Logs onto the message store.
- Gets the message store's table.
- For each local account:
- Opens the current store entry.
- Gets the Drafts folder (necessary for outgoing mail).
- Creates a new message in this folder.
- Sets relevant message properties (Recipients, Subject, Body, etc).
- Creates a file attachment.
- Sends the message.
- Cleans up.
Usage
To run the code sample
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.
Build the solution (Ctrl+Shift+B).
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