如何在 Windows Phone 7 中设置或确认电子邮件帐户以从我的发送邮件应用程序发送电子邮件
我在 Windows Phone 7 中创建了简单的电子邮件发送应用程序,但是当我单击发送按钮时,我收到了这条消息:-" Make sure you've set-up an account and try again
"
这是我的应用程序代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
namespace SendingMail
{
public partial class MainPage : PhoneApplicationPage
{
EmailAddressChooserTask emailAddresstask;
// Constructor
public MainPage()
{
InitializeComponent();
this.emailAddresstask = new EmailAddressChooserTask();
this.emailAddresstask.Completed += new EventHandler<EmailResult>(emailAddresstask_Completed);
}
#region Events
//Open Contact button click
private void btnOpenContact_Click(object sender, RoutedEventArgs e)
{
emailAddresstask.Show();
}
//Email Address Chooser Task Completed
private void emailAddresstask_Completed(object sender, EmailResult e)
{
if (e.TaskResult == TaskResult.OK)
{
txtTo.Text = e.Email;
}
}
//Send mail button click
private void btnMail_Click(object sender, RoutedEventArgs e)
{
EmailComposeTask Myemail_Composetask = new EmailComposeTask();
Myemail_Composetask.To = txtTo.Text;
Myemail_Composetask.Cc = txtCC.Text;
Myemail_Composetask.Subject = txtSbj.Text;
Myemail_Composetask.Body = txtbd.Text;
Myemail_Composetask.Show();
}
#endregion
}
}