![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Section Contents
This example illustrates the EPOC message client APIs, particularly the Send As API.
Found in: \epoc32ex\msg
Msgexapp
is an example of how to add messaging capabilities to an application. It presents a simplified e-commerce scenario, in which the user chooses options from menus put before him or her ("menus" is unusually meaningful here, since the example imagines choosing options from a restaurant). The user chooses with which of their email services to send the message. An Internet e-mail message is then automatically created, and the options written into it. The user finally has the option to put the resulting message into the Outbox for later sending from the Email client, or to send the message immediately.
As usual, the application is divided into user interface and engine parts.
The user interface, defined in Msgexapp.cpp
, is a simple EIKON console window. Most of the functionality is in the CConsoleControl class. CConsoleControl::OfferKeyEventL() gets keyboard input, interprets it as a menu choice, and communicates that choice to the engine. CConsoleControl::doMenu() prints the available menu choices on the screen.
The most interesting function is probably CConsoleControl::SendNowL(), which is called when the user chooses to send the message immediately. The engine requires that the caller supply an active object which will be signalled complete when the asynchronous send operation is complete. An active object class COpComplete is defined for this purpose.
The engine, defined in Msgexeng.cpp
, contains two classes, CMsgExEngine and TRenderingSendAsObserver.
CMsgExEngine is the main class that offers public functions to a user interface. It possesses a collection of accessor and mutator functions that allow the user interface to obtain the available menu options, and to tell the engine which option was chosen respectively. The key functions are, however, concerned with sending a message based on the options chosen. These are:
SendToOutboxL(): this uses the CSendAs class to create a message, set its type, subject, body, and address, and save it to the Outbox.
SendNowL(): this first calls SendToOutboxL() to create the message and put it in the Outbox. CSendAs does not however supply a function to send a message immediately. We can do this though the CBaseMtmUi interface. The first step is therefore to get a CBaseMtmUi-derived object for the message type we are trying to send. This is done in SetMTMUiL(). We can then set the context to the service to which we want to send, and use CBaseMtmUi::CopyToL() to send it.
Msgexapp
is an EIKON application, and is run in the normal way from the Extras bar.
A few set up steps are required before Msgexapp
can be built and run.
Also to
actually send messages, Msgexapp
will require a real email address to which to send. The address is set by the KSMTPAddress string constant declared in Msgexeng.h
. Before building, you must set this to a real address appropriate to your network, i.e._LIT(KSMTPAddress,"<your email address>");
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |