Create your own email editor or viewer

From Nokia Developer 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: File:EmailEditor.zip

If you want to make your own proprietary email protocol then integrated this example with the following example. http://www.developer.nokia.com/info/sw.nokia.com/id/ec735e80-0bbb-491c-b5c2-3fa8df09dfb2/S60_3rd_Edition_Creating_Custom_Message_Type_Modules.html

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