Namespaces
Variants
Actions

Create Local SMS

Jump to: navigation, search
Article Metadata

Article
Created: rathodavinash (27 Jun 2007)
Last edited: hamishwillee (03 Feb 2012)


Using the following code an SMS can be created in the local Inbox. The user gets a new message with the SMS alert tone (if profile not silent). SMS does not use network services ,its just created locally. This example needs intialization and setup of some MTM related classes which is not mention here, please refer here to get more information about it

void CMobloggerPhotoEngine::SMS2Inbox()
{
iSendingSms=ETrue;
TBuf<10> aAddress(_L("Nokia"));
TBuf<20> aDescription(_L("Important Message"));
 
_LIT(KTxt1,"Hi phone owner, how r u?");
 
TBuf<150> iMessage;
iMessage.Copy(KTxt1);
 
iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
 
iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox
 
iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
 
CSmsHeader& iHeader = iSmsMtm->SmsHeader();
iHeader.SetFromAddressL(aAddress);
 
 
CRichText& body = iSmsMtm->Body();
body.Reset();
body.InsertL(0, iMessage);
 
TMsvEntry entry = iSmsMtm->Entry().Entry();
entry.SetInPreparation(EFalse);
entry.SetVisible(ETrue);
entry.iDate.HomeTime();
entry.iDescription.Set(aDescription);
entry.iDetails.Set(aAddress);
entry.SetUnread(ETrue);
 
 
iSmsMtm->Entry().ChangeL(entry);
iSmsMtm->SaveMessageL();
}

the following are the header files required

#include <msvapi.h>
#include <mtclreg.h>
#include <SMSCLNT.h>
#include <msvstd.h>
#include <smut.h>
#include <txtrich.h>
#include <SMUTHDR.h>
 
LIBRARY msgs.lib smcm.lib gsmu.lib

Related Links:

This page was last modified on 3 February 2012, at 07:10.
137 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved