View a printable version of the current page.
  Wiki > Symbian Developer Network Public Wiki > ... > SDN Wiki Competition 2007 entries > Read Messages from Inbox
  Read Messages from Inbox
Added by eswar_illuri, last edited by Rodney De Gale on Feb 15, 2008  (view change)
Labels: 
(None)

The ReadMailFolderL()- function shows how you could get the list of available messages from the inbox. For reading other folders, you just need to change the KMsvGlobalInBoxIndexEntryId to be one of the following:

  • KMsvGlobalOutBoxIndexEntryId (outbox folder)
  • KMsvDraftEntryId (Drfats folder)
  • KMsvSentEntryId (sent messages folder)

And if you want to get all other messages (non SMS), just comment out the line checking if the message entry's MTM is KUidMsgTypeSMS. Note that aSession needs to be correctly opened before this function can be called.

void ReadMailFolderL(CMsvSession\* aSession,RArray<TMsvEntry>& aMailArray)
{
CMsvEntry * Entrie = aSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
CleanupStack::PushL(Entrie);
if(Entrie->Count())
{
TMsvSelectionOrdering MySortType;

//MySortType.SetSorting(EMsvSortByDetails);
MySortType.SetSorting(EMsvSortByDate);

Entrie->SetSortTypeL(MySortType);

CMsvEntrySelection\* entries = Entrie->ChildrenL();
CleanupStack::PushL(entries);

for(TInt i = (Entrie->Count() - 1); i >= 0; i--)
{
if(Entrie->ChildDataL(entries->At(i)).iMtm == KUidMsgTypeSMS)
{ aMailArray.Append(Entrie->ChildDataL(entries->At(i))); }
}

CleanupStack::PopAndDestroy(entries);
}

CleanupStack::PopAndDestroy(1);//Entrie
}

You could use the aMailArray already to fill your list box, but if you need to get the phone number of the sender and the whole message body, you could utilize following GetMessageL()-function.

void GetMessageL(CMsvSession\* aSession,TMsvEntry aMailEntry,TDes& aFrom,TDes& aMessage)
{
if(aMailEntry.iMtm == KUidMsgTypeSMS)
{
CSmsClientMtm* SmsMtm = STATIC_CAST(CSmsClientMtm*,iMtmReg->NewMtmL(KUidMsgTypeSMS));
CleanupStack::PushL(SmsMtm);

SmsMtm->SwitchCurrentEntryL(aMailEntry.Id());
SmsMtm->LoadMessageL();

aFrom.Copy(SmsMtm->SmsHeader().Message().ToFromAddress());

if(!aFrom.Length())
{
if(SmsMtm->AddresseeList().Count())
{ aFrom.Copy(SmsMtm->AddresseeList().MdcaPoint(0)); }
}

aMessage.Copy(SmsMtm->Body().Read(0));

CleanupStack::PopAndDestroy(SmsMtm);
SmsMtm = NULL;
}
}
[live-web] Interactive Services Terms & Conditions of use | Terms of use | Privacy policy | Media Center | Contact us | © 2008 Symbian