You Are Here:

Community: Wiki

This page was last modified on 3 September 2009, at 20:30.

Reading SMS from Inbox

From Forum Nokia Wiki

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)); //Warning! This will give you only first 256 symbols. Check SmsMtm->Body().DocumentLength() for actual length.
 
CleanupStack::PopAndDestroy(SmsMtm);
SmsMtm = NULL;
}
}

Related Links:

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 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fMessageE5fhandlingE5finE5fJavaE5fPlatfromE2cE5fMicroE5fE45ditionE5fE28JavaE5fME45E29X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZmessagingQ qfnZtopicQUqfnTopicZsmsQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxmessagingX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx3E2E5000X