×
Namespaces

Variants
Actions
(Redirected from Create Local SMS)

Create SMS locally in inbox using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Article
Created: rathodavinash (27 Jun 2007)
Last edited: hamishwillee (16 Oct 2013)


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 16 October 2013, at 12:44.
80 page views in the last 30 days.
×