2

how to send SMS after 4 days from a Symbian app by running the application in the bachground. Means application sends SMS after 4 days? Is that possible?

Please reply soon.

mauris
  • 42,982
  • 15
  • 99
  • 131

1 Answers1

2

I don't think you would want to achieve this by running your application in the background for 4 days. For a start, if the phone was rebooted or ran out of battery in that time then the SMS wouldn't get sent when it was switched on again.

Instead, you can use the message centre API to schedule the SMS to be sent at a particular time.

The TMsvEntry class lets you call:

SetScheduled(ETrue);
SetSendingState(KMsvSendStateScheduled);

and then you can set TMsvEntry::iDate which is a TTime to the date/time you want the message to be sent.

This example shows how to send an SMS, try looking at:

void CSmsEngine::SendSmsL(const TDesC& aAddr, const TDesC& aMsg)

Comment out the SendSMSInThirdEditionL call, since you need to use the older API. Make your changes in:

TMsvId CSMSExampleMtmsEngine::CreateSMSMessageL(const TDesC& aAddress,

                                              const TDesC& aMessage)

Alternatively, if what you want to achieve is to send an SMS every 4 days, then you can use the Symbian Task Scheduler to do this. You can create an EXE which sends the SMS, then create a task which will run the EXE every 4 days. It will not keep anything running in the background so it won't waste battery, and it will remember to run the task even if you reboot the phone in between runs, since it persists the schedule to disk.

This example shows how to create a task - so in the DoRunTaskL function you can send an SMS, for instance.

This example shows how to schedule the task itself.

So to start your SMS sending schedule you would need to do something like that but edit the schedule to be every 4 days.

I would say that this is a relatively advanced programming challenge on Symbian. So if you are new I'd recommend doing some of the tutorials, reading the books etc. before starting it.

RivieraKid
  • 5,923
  • 4
  • 38
  • 47
Rob Charlton
  • 763
  • 1
  • 5
  • 11
  • Thanks alot...where i set these 2 lines SetScheduled(ETrue); SetSendingState(KMsvSendStateScheduled); I am very new to symbian? –  Nov 04 '09 at 12:04
  • Sorry i think Question is bit differentIs it possible to invoke the app after every 4 days and then it send the sms?i think in this i dont need sms scheduler.. Thanks –  Nov 04 '09 at 12:30
  • New to Symbian? You might want to look at some of the resources indicated here: http://stackoverflow.com/questions/200441/startup-point-for-symbian-embedded-programming-learning Your question doesn't say that you want to send an SMS every 4 days, just that you want to send one _after_ 4 days. Please be clear. I'll post another answer for that. – Rob Charlton Nov 04 '09 at 14:07