0

我为 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
    }
}
4

1 回答 1

0

你不需要这样做(而且你也不能这样做)。如果手机上没有设置电子邮件帐户,操作系统已经提示用户创建一个电子邮件帐户。

于 2012-12-04T17:01:39.630 回答