Add SMS to Inbox
| Wed, 2004-08-11 15:27 | |
|
I want to add an SMS to the Inbox and set the number that the SMS has been received from.
Using the CSendAs class it is possible to create a new SMS in the Inbox: // where sendAs is a pointer to a CSendAs object sendAs->CreateMessageL(KMsvGlobalInBoxIndexEntryId); and set the 'to' address of the SMS: TMsvEntry entry = sendAs->ClientMtm().Entry().Entry(); entry.iDetails.Set(*address); sendAs->ClientMtm().Entry().ChangeL(entry); However I need to set the 'from' address and this doesn't appear to be possible using TMsvEntry. The class CSmsHeader has a function SetFromAddressL that appears to do what I want but I can't find any documentation or example code on how it should be used. Does anyone have any suggestions? Thanks J |
|






Forum posts: 31
void CpssSMSEngine::ConstructL()Â {
  iSession = CMsvSession::OpenAsyncL(*this);
}
void CpssSMSEngine::CreateSMSMessageL(const TDesC& aAddress, const TDesC& aDescription, const TDesC& aMessage) {
 iMtmRegistry = CClientMtmRegistry::NewL(*iSession);
 iSmsMtm = STATIC_CAST( CSmsClientMtm*, iMtmRegistry->NewMtmL(KUidMsgTypeSMS));
 iSmsMtm->SwitchCurrentEntryL(KMsvGlobalInBoxIndexEntryId); //inbox
 //iSmsMtm->SwitchCurrentEntryL(KMsvDraftEntryId); //draft
 iSmsMtm->CreateMessageL(KUidMsgTypeSMS.iUid);
 //iSmsMtm->AddAddresseeL(aAddress); //to address if need
 CSmsHeader& iHeader = iSmsMtm->SmsHeader();
 iHeader.SetFromAddressL(aAddress);
 CRichText& body = iSmsMtm->Body();
 body.Reset();
 body.InsertL(0, aMessage);
Â
 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(); Â
}
Regards
Ari
Forum posts: 21
Forum posts: 31
Yes I have tried it myself. I have used this only in testing, so only thing I want is that message born in inbox. You could be right, but you can put still from number.
Regards
Ari
Forum posts: 21
Forum posts: 31
Yes you are right it won't show in the details and that's too bad. But in testing this works cause you can get from address when reading this message as well:
CSmsClientMtm* tempSmsMtm = STATIC_CAST(CSmsClientMtm*, clientMtm);
CSmsHeader& header = tempSmsMtm->SmsHeader();
iSender.Copy(header.FromAddress());
Maybe CSendAs will do that kind of message where you can see from number in the details. I don't know I haven't try.
Regards
Ari