Listado de código
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace F.Phone.IO
{
public class Messaging
{
public static bool ShowComposingTask { get; set; }
public static string ChoosenEmailAddresses { get; set; }
public static string ChoosenPhoneNumbers { get; set; }
public static string BodyTemplate { get; set; }
public static string SubjectTemplate { get; set; }
/// <summary>
///
/// </summary>
public static void ChooseEmailContacts() {
Microsoft.Phone.Tasks.EmailAddressChooserTask contacts = new Microsoft.Phone.Tasks.EmailAddressChooserTask();
contacts.Completed += new EventHandler<Microsoft.Phone.Tasks.EmailResult>(contacts_Completed);
contacts.Show();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void contacts_Completed(object sender, Microsoft.Phone.Tasks.EmailResult e)
{
if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) {
ChoosenEmailAddresses = e.Email;
if (ShowComposingTask ) SendEmail(e.Email, string.Empty, SubjectTemplate, BodyTemplate);
}
}
/// <summary>
///
/// </summary>
public static void ChoosePhoneContacts() {
Microsoft.Phone.Tasks.PhoneNumberChooserTask contacts = new Microsoft.Phone.Tasks.PhoneNumberChooserTask();
contacts.Completed += new EventHandler<Microsoft.Phone.Tasks.PhoneNumberResult>(contacts_Completed);
contacts.Show();
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
static void contacts_Completed(object sender, Microsoft.Phone.Tasks.PhoneNumberResult e)
{
if (e.TaskResult == Microsoft.Phone.Tasks.TaskResult.OK) {
ChoosenPhoneNumbers = e.PhoneNumber;
if (ShowComposingTask) SendSMS(e.PhoneNumber, BodyTemplate);
}
}
/// <summary>
///
/// </summary>
/// <param name="to"></param>
/// <param name="cc"></param>
/// <param name="subject"></param>
/// <param name="body"></param>
public static void SendEmail(string to, string cc, string subject, string body) {
Microsoft.Phone.Tasks.EmailComposeTask email = new Microsoft.Phone.Tasks.EmailComposeTask();
email.To = to;
email.Subject = subject;
email.Cc = cc;
email.Body = body;
email.Show();
}
/// <summary>
///
/// </summary>
/// <param name="to"></param>
/// <param name="body"></param>
public static void SendSMS(string to, string body)
{
Microsoft.Phone.Tasks.SmsComposeTask sms = new Microsoft.Phone.Tasks.SmsComposeTask();
sms.To = to;
sms.Body = body;
sms.Show();
}
}
}