You Are Here:

Community: Wiki

This page was last modified on 8 September 2009, at 17:16.

Create your own email editor or viewer

From Forum Nokia Wiki

Reviewer Approved   

Contents

Overview

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

Source:

CDesCArrayFlat* CEmailEditorView::GetEMailFromPhoneBookL( TBool& aSuccess )
{
 
aSuccess = EFalse;
RPbkViewResourceFile PbkResourceFile(*iCoeEnv);
if (!iPbkEngine)
{
iPbkEngine = CPbkContactEngine::NewL(&iEikonEnv->FsSession());
}
if (!PbkResourceFile.IsOpen())
{
PbkResourceFile.OpenL();
}
CDesCArrayFlat* addresses = new (ELeave) CDesCArrayFlat( 8 ); // granularity = 8
CleanupStack::PushL(addresses);
 
 
CPbkMultipleEntryFetchDlg::TParams params;
params.iContactView = &iPbkEngine->FilteredContactsViewL(CContactDatabase::EMailable);
 
CPbkMultipleEntryFetchDlg* fetchDlg = CPbkMultipleEntryFetchDlg::NewL(
params,
*iPbkEngine);
fetchDlg->SetMopParent(this);
const TInt res(fetchDlg->ExecuteLD());
fetchDlg = NULL;
 
 
if (res)
{
CleanupStack::PushL(params.iMarkedEntries);
 
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::TParams(*pbkItem);
pbkParams.SetUseDefaultDirectly(ETrue);
CPbkEmailAddressSelect* dlg = new(ELeave) CPbkEmailAddressSelect();
 
// Shows "select email address popup" if necessary
if (dlg->ExecuteLD( pbkParams ))
{
const TPbkContactItemField* selectedField =
pbkParams.SelectedField();
if (selectedField)
{
TPtrC address = selectedField->Text();
aSuccess = ETrue;
addresses->AppendL(address);
 
}
}
CleanupStack::PopAndDestroy( pbkItem ); // pbkItem
}
 
CleanupStack::PopAndDestroy( params.iMarkedEntries );
}
 
CleanupStack::Pop( addresses );
 
 
delete iPbkEngine;
iPbkEngine = NULL;
PbkResourceFile.Close();
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.forum.nokia.com/info/sw.nokia.com/id/ec735e80-0bbb-491c-b5c2-3fa8df09dfb2/S60_3rd_Edition_Creating_Custom_Message_Type_Modules.html

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
User Rating: qfnZuserE5FratingQNx4E2E0000X