tags:

views:

189

answers:

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.

+2  A: 

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: http://bit.ly/o3LDf . 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: http://wiki.forum.nokia.com/index.php/CS000986%5F-%5FCreating%5Fand%5Fregistering%5Fa%5Ftask%5Fhandler%5Fwith%5FRScheduler shows how to create a task - so in the DoRunTaskL function you can send an SMS, for instance.

This example: http://wiki.forum.nokia.com/index.php/CS000987%5F-%5FCreating%5Fpersistent%5Fand%5Ftransient%5Fschedules%5Fwith%5FRScheduler 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.

Rob Charlton
Thanks alot...where i set these 2 lines SetScheduled(ETrue);SetSendingState(KMsvSendStateScheduled);I am very new to symbian?
sonia
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
sonia
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-learningYour 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
A: 

Hello Rob, Thanks for ur ans.. well i got an project that i have to fetch 4 days call logs and after 4 days i have to send the all call logs time via sms.So app will Run in background and it get invoke every 4 days to send the sms.. plz reply soon if u have an idea abt this

sonia