如何提示用户登录我的电子邮件发送应用程序(Windows Phone 7)

时间:2012-12-04 16:24:34

标签: c# .net windows-phone-7 email

我为Windows Phone 7创建了一个简单的电子邮件应用程序,但我需要设置我的电子邮件帐户以从我的应用程序发送电子邮件。

所以请告诉我如何提示用户登录我的电子邮件发送应用程序以发送电子邮件(Windows Phone 7)

这是我的应用程序代码:

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
    }
}

1 个答案:

答案 0 :(得分:0)

你不需要这样做(你无论如何都不能)。如果手机上没有设置电子邮件帐户,操作系统已提示用户创建电子邮件帐户。