Add SMS to Inbox

Login to reply to this topic.
Wed, 2004-08-11 15:27
Joined: 2004-08-11
Forum posts: 1
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

Thu, 2005-06-23 06:47
Joined: 2005-05-17
Forum posts: 31
Re: Add SMS to Inbox
Perhaps you have resolved the problem. You can add message to the inbox like following:

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
Wed, 2005-06-29 11:39
Joined: 2005-02-03
Forum posts: 21
Re: Add SMS to Inbox
arik, did you try to do that by yourself? Though the message is really created in Inbox it seems to be an outgoing one.
Wed, 2005-06-29 11:58
Joined: 2005-05-17
Forum posts: 31
Re: Add SMS to Inbox
Quote from: George Tohn
arik, did you try to do that by yourself? Though the message is really created in Inbox it seems to be an outgoing one.

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
Wed, 2005-06-29 12:06
Joined: 2005-02-03
Forum posts: 21
Re: Add SMS to Inbox
Indeed, calling SetFromAddressL() won't cause any problem. But it won't show in message details as well Sad
Wed, 2005-06-29 12:31
Joined: 2005-05-17
Forum posts: 31
Re: Add SMS to Inbox
Quote from: George Tohn
Indeed, calling SetFromAddressL() won't cause any problem. But it won't show in message details as well Sad

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
  • Login to reply to this topic.