Reputation: 213
I want to send an sms or email automatically in a emergency situation without any user interaction.
The following code helps me in composing the sms or email but need user to tap the send button
private static void SendSms(string mobileNumber)
{
SmsComposeTask smsComposeTask = new SmsComposeTask();
smsComposeTask.To = mobileNumber;
smsComposeTask.Body = "Alert: Save me! My last location was -";
smsComposeTask.Show();
}
private static void SendEmail(string emailAddress)
{
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = emailAddress;
emailComposeTask.Subject = "Alert: Save me!";
emailComposeTask.Body = "Please save me my last location was - ";
emailComposeTask.Show();
}
Isn't there any way by which i can by pass the user tap action to send the sms?
Upvotes: 1
Views: 1862
Reputation: 977
Although it's not as easy as using the built-in features, it can be done if you're willing to use web services. For example, twilio will let you send SMS messages for around $0.01/message (there are other SMS services out there so better pricing may be available).
If you're adventurous enough, you could even write your own SMS service that could send messages without the help of 3rd parties (again, not recommended because the ROI likely wouldn't be there unless you were sending a ton of messages).
Sending e-mail via a web service would likely be a simpler solution as it's not hard to write some .NET code that will send e-mail messages for you (when you have the full .NET Framework at your disposal).
Once you have a web service that can send messages for you, it's a simple matter for your phone app to call the service without any user interaction.
Upvotes: 3
Reputation: 4593
It is not possible in Windows Phone. You can prepare an SMS orEmail, but user must be sending it out.
Upvotes: 3