Sending E-mail
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 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.
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.
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