symbian mtm操作
2010-08-20 01:50:00 来源:WEB开发网//构建消息索引
TMsvEntry newIndexEntry;
newIndexEntry.iDate.HomeTime();
newIndexEntry.iMtm = KUidMsgTypeSMS;
newIndexEntry.iType = KUidMsvMessageEntry;
//in 3rd edition crashes here if capabilities are wrong
newIndexEntry.iServiceId = iSmsMtm->ServiceId();
newIndexEntry.iDetails.Set(aName);//aName为收件人名称
newIndexEntry.iDescription.Set(aContent.Left(LEN));
newIndexEntry.SetUnread(ETrue);
iSmsMtm->Entry().CreateL(newIndexEntry);
TMsvId smsId = newIndexEntry.Id();
iSmsMtm->SwitchCurrentEntryL(smsId);
//填充消息存储区
iSmsMtm->AddAddresseeL(aAddr);//aAddr为收件人号码,信息位于消息头中
CRichText& body = iSmsMtm->Body();//消息正文
body.Reset();
body.InsertL(0, *iSmsContext);
//提交保存
iSmsMtm->SaveMessageL();
注:当然如果要发送的短信,还需要进行具体的设定,这部分将在发送消息里面详述,这里只是做为普通的创建消息,与收件箱中消息进行比较,具体见下面代码示例。
//在收件箱中创建短信
const TInt LEN = 12;
//转入收件箱
iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId);
//构建消息索引
TMsvEntry newIndexEntry;
//newIndexEntry.iDate.HomeTime();//收件箱短信索引头在CSmsHeader中设置
newIndexEntry.iMtm = KUidMsgTypeSMS;
newIndexEntry.iType = KUidMsvMessageEntry;
//in 3rd edition crashes here if capabilities are wrong
newIndexEntry.iServiceId = iSmsMtm->ServiceId();
newIndexEntry.iDetails.Set(aAddr);
newIndexEntry.iDescription.Set(aContent.Left(LEN));
newIndexEntry.SetUnread(ETrue);
iSmsMtm->Entry().CreateL(newIndexEntry);
TMsvId smsId = newIndexEntry.Id();
iSmsMtm->SwitchCurrentEntryL(smsId);
//填充消息存储区
更多精彩
赞助商链接