Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Create your own email editor or viewer

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: mahbub_s60 (30 May 2008)
Last edited: hamishwillee (14 Jun 2013)



When we need to have our own email editor or viewer then this example can be used for that purposes. In this example we have provided two main features of the email editor. Inserting email address from phone book, resizing the editor control and making line to the editor. Though S60 email editor shows name only and those email address are embedded under the name. In this example we show the email address directly.

How to insert Email address

Hearders Required:

#include <badesca.h> //CDesCArrayFlat
#include <rpbkviewresourcefile.h> //RPbkViewResourceFile
#include <cpbkcontactengine.h> //CPbkContactEngine
#include <cpbkmultipleentryfetchdlg.h> //CPbkMultipleEntryFetchDlg
#include <cntdef.h> //TContactItemId
#include <cpbkcontactitem.h> // CPbkContactItem
#include <cpbkemailaddressselect.h> //CPbkEmailAddressSelect
#include <tpbkcontactitemfield.h> //TPbkContactItemField

Library required:

LIBRARY  pbkview.lib //RPbkViewResourceFile ,CPbkMultipleEntryFetchDlg ,CPbkEmailAddressSelect
LIBRARY pbkeng.lib ////CPbkContactEngine , CPbkContactItem ,TPbkContactItemField

Capabilities needed:

Capability  ReadDeviceData ReadUserData WriteDeviceData WriteUserData


CDesCArrayFlat* CEmailEditorView::GetEMailFromPhoneBookL( TBool& aSuccess )
aSuccess = EFalse;
RPbkViewResourceFile PbkResourceFile(*iCoeEnv);
if (!iPbkEngine)
iPbkEngine = CPbkContactEngine::NewL(&iEikonEnv->FsSession());
if (!PbkResourceFile.IsOpen())
CDesCArrayFlat* addresses = new (ELeave) CDesCArrayFlat( 8 ); // granularity = 8
CPbkMultipleEntryFetchDlg::TParams params;
params.iContactView = &iPbkEngine->FilteredContactsViewL(CContactDatabase::EMailable);
CPbkMultipleEntryFetchDlg* fetchDlg = CPbkMultipleEntryFetchDlg::NewL(
const TInt res(fetchDlg->ExecuteLD());
fetchDlg = NULL;
if (res)
const TInt count(params.iMarkedEntries->Count());
for (TInt i = 0; i < count; ++i)
const TContactItemId cid = (*params.iMarkedEntries)[i];
CPbkContactItem* pbkItem = iPbkEngine->ReadContactLC(cid);
CPbkEmailAddressSelect::TParams pbkParams =
CPbkEmailAddressSelect* dlg = new(ELeave) CPbkEmailAddressSelect();
// Shows "select email address popup" if necessary
if (dlg->ExecuteLD( pbkParams ))
const TPbkContactItemField* selectedField =
if (selectedField)
TPtrC address = selectedField->Text();
aSuccess = ETrue;
CleanupStack::PopAndDestroy( pbkItem ); // pbkItem
CleanupStack::PopAndDestroy( params.iMarkedEntries );
CleanupStack::Pop( addresses );
delete iPbkEngine;
iPbkEngine = NULL;
return addresses;

How to draw underline in editor

The underline are icons created by AknsUtils::CreateGulIconL() and the background is saved by calling SetSuppressBackgroundDrawing() method. The line can be adjusted as calculating the text height and resizing it.

Capability Used

To access address we need following capability. So self signed would not work in this case. CAPABILITY ReadUserData WriteUserData WriteDeviceData ReadDeviceData

Example Applications

The application is tested with E70, can be found here:

If you want to make your own proprietary email protocol then integrated this example with the following example.

This page was last modified on 14 June 2013, at 06:51.
33 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.