Symbian CreateAndSendMessageL发送彩信

本文介绍在Symbian系统中两种不同的彩信发送方式:一是通过编辑框引导用户发送;二是后台静默发送,无需用户交互。涉及消息创建、内容设置及发送流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Symbian CreateAndSendMessageL发送彩信1 用程序调用彩信的编辑框进行彩信发生,通常用在好友推荐的场合. 程序把彩编辑框调起来.插入相应的内容并把焦点设置到输入号码处. 让用户设置号码即可以发送. 让我们看看如何实现 void CSendMMSTestAppUi::CreateAndSendMessageL(const TDesC& desContent) { // create empty message CMessageData* message = CMessageData::NewLC(); CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(); CleanupStack::PushL(paraFormatLayer); CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(); CleanupStack::PushL(charFormatLayer); CRichText* messageBodyContent = CRichText::NewL(paraFormatLayer, charFormatLayer); CleanupStack::PushL(messageBodyContent); messageBodyContent->InsertL(0, desContent); message->SetBodyTextL(messageBodyContent); // start message editor through SendUI sendAppUi->CreateAndSendMessageL(KSenduiMtmSmsUid, message, KNullUid); CleanupStack::PopAndDestroy(4); } 以上代码在N73/N95/E71上测试通过 Symbian MTM发送彩信2 上一篇blog文我介绍了用编辑框发彩信,但是可能在某些情况下我们需要 暗地里发短信.也就是让用户不知道.这种情况怎么实现呢? 让我们来看下面的实现方案 void CMMSSender::SendMMSL(const TDesC& aAddress,const TDesC& aContent) { CMsvEntry* entry = CMsvEntry::NewL(*iSession,KMsvGlobalOutBoxIndexEntryId ,TMsvSelectionOrdering()); CleanupStack::PushL(entry); // Set context to the parent folder (Outbox) iMmsMtm->SwitchCurrentEntryL( entry->EntryId() ); // Create new message in the parent folder (Outbox) and // set it as the current context iMmsMtm->CreateMessageL( iMmsMtm->DefaultServiceL() ); CleanupStack::PopAndDestroy(); // entry //设置手机号码,发送的手机号码 iMmsMtm->AddAddresseeL(aAddress); //发送彩信的标题 // Setting message subject iMmsMtm->SetSubjectL(_L("/x597D/x53CB/x63A8/x8350/x4E50/x79C0")); // Opening store CMsvStore* store = iMmsMtm->Entry().EditStoreL(); CleanupStack::PushL(store); _LIT(KFileName, "mmsexample.txt"); TMsvAttachmentId attachId = KMsvNullIndexEntryId; //创建文本类型的附件,彩信也可以发布图像音乐类型的附件 iMmsMtm->CreateTextAttachmentL(*store, attachId, aContent, KFileName); store->CommitL(); CleanupStack::PopAndDestroy(); // store TMsvEntry ent = iMmsMtm->Entry().Entry(); // Set InPreparation to false ent.SetInPreparation(EFalse); // Mark as visible, after this the message can be seen in Outbox and, // after sending, in Sent folder. ent.SetVisible(ETrue); iMmsMtm->Entry().ChangeL(ent); // Commit changes // Save the changes iMmsMtm->SaveMessageL(); // Start sending the message via the Server MTM to the MMS server CMsvOperationWait* wait = CMsvOperationWait::NewLC(); wait->iStatus = KRequestPending; CMsvOperation* op = NULL; //发送信息 op = iMmsMtm->SendL(wait->iStatus ); wait->Start(); CleanupStack::PushL( op ); CActiveScheduler::Start(); // The following is to ignore the completion of other active objects. // It is not needed if the app has a command absorbing control (using CCommandAbsorbingControl). while( wait->iStatus == KRequestPending ) CActiveScheduler::Start(); CleanupStack::PopAndDestroy(2); // op, wait }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值