This page was last modified 11:24, 12 December 2007.
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)); CleanupStack::PopAndDestroy(SmsMtm); SmsMtm = NULL; } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| message filtering | susha | Mobile Java General | 2 | 2007-02-25 09:47 |
| SMS stuck in outbox | JOM | Python | 4 | 2008-04-25 04:06 |
| sms ( symbian OS ) | tomereg | Mobile Java General | 4 | 2004-02-10 08:02 |
| Reading Messages in BINARY/as-is Mode? | www_peach | General Symbian C++ | 0 | 2005-09-12 04:53 |
| Is there a substitute for PushRegisters in MIDP1.0 | acho_vt | Mobile Java Networking & Messaging & Security | 1 | 2004-03-28 12:32 |
