我为 Windows Phone 7 创建了一个简单的电子邮件应用程序,但我需要设置我的电子邮件帐户以从我的应用程序发送电子邮件。
我想在我的应用程序中添加一个登录屏幕,这样我就可以设置我的电子邮件帐户,当我输入我的电子邮件用户 ID 或密码时,我的应用程序应该将我带到撰写邮件屏幕。
我还希望它记住我的用户名或密码,直到我注销为止。
这是我的应用程序代码:
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
}
}