现在的位置: 首页 > 综合 > 正文

Symbian中调用系统发短信服务

2013年09月19日 ⁄ 综合 ⁄ 共 1054字 ⁄ 字号 评论关闭

见过几种方法,经过本人试验,这种方法是最好的。

添加库文件:

sendui.lib

etext.lib

添加头文件:

#include <cmessagedata.h>//CMessageData
#include <TXTFMLYR.H> //CParaFormatLayer
#include <TXTRICH.H> //CRichText
#include <sendui.h> //CSendUi
#include <SendUiConsts.h>//KSenduiMtmSmsUid

 

 

实现代码:

 

void CNewsReaderAppUi::OpenSms()
{
 _LIT(KAddress, "07738123456");
 _LIT(KAlias, "Sam");
 _LIT(KBodyData, "This is the message body");

 CSendUi* iSendUi = CSendUi::NewL();
 CMessageData* message = CMessageData::NewLC();
 CParaFormatLayer* iParaFormatLayer = CParaFormatLayer::NewL();
 CCharFormatLayer* iCharFormatLayer = CCharFormatLayer::NewL();
 CRichText* iRichText = CRichText::NewL(iParaFormatLayer,iCharFormatLayer);

 TInt pos= 0;
 iRichText->InsertL(pos,KBodyData);

 // Set the body text
 message->SetBodyTextL(iRichText);//发送的内容
 message->AppendToAddressL(KAddress);//发送的号码

 // start message editor through SendUI
 iSendUi->CreateAndSendMessageL( KSenduiMtmSmsUid, message,KNullUid, EFalse );
 //============================================
 CleanupStack::PopAndDestroy( message );

 delete iParaFormatLayer;
 delete iCharFormatLayer;
 delete iRichText;
 delete iSendUi;

}

 

谢谢!

抱歉!评论已关闭.