Symbian (Read Inbox)读取收件箱的内容
2010-02-21 15:53:00 来源:WEB开发网收件箱里的消息通常是有多种的,我们今天主要谈谈常用的三种!!!
1.短消息
2.彩信
3.Bluetooth在收件箱中的情况
让我们来试着把收件箱中的消息都枚举出来!!
//好让我们看看如何处理吧!!!
void CMessageAllTestAppUi::ListInboxContent()
{
// Access the Inbox
TMsvSelectionOrdering sort;
CMsvEntry* inboxContext = CMsvEntry::NewL(*iSession,
KMsvGlobalInBoxIndexEntryId, sort);
CleanupStack::PushL(inboxContext);
// Get all entries in the Inbox
//得到收件箱中所有目录
CMsvEntrySelection* entries = inboxContext->ChildrenL();
CleanupStack::PushL(entries);
TInt messages = entries->Count();
//得到消息总条数
for (TInt i = 0; i < messages; i++)
{
//取出每条消息ID
TMsvId entryID = entries->At(i);
iSmsMtm->SwitchCurrentEntryL(entryID);
//根据消息ID得到相关的属性
CMsvEntry* entry = iSession->GetEntryL((*entries)[i]);
CleanupStack::PushL(entry);
if(entry->Entry().iMtm == KUidMsgTypeSMS)//短信
{
CMsvStore* inboxStore= entry->ReadStoreL();
CleanupStack::PushL(inboxStore);
RLog::LogPoor(_L("get inboxStore"));
if (inboxStore->HasBodyTextL())
{
RLog::LogPoor(_L("Has body text"));
// Get the sender's details
TMsvEntry smsEntry = entry->Entry();
HBufC* aText = smsEntry.iDetails.AllocL();
CleanupStack::PushL(aText);
//得到详细信息,这里可以拿到发信人的电话号码.
RLog::LogPoor(aText->Des());
CleanupStack::PopAndDestroy(); // aText
// Get the SMS contents
//得到短信内容
CRichText& richText= iSmsMtm->Body();
inboxStore->RestoreBodyTextL(richText);
更多精彩
赞助商链接