邮件撰写任务不工作Windows phone 8.1
本文关键字:Windows phone 工作 写任务 | 更新日期: 2023-09-27 18:18:18
如何在Windows phone 8.1应用程序中使用按钮发送电子邮件?
EmailRecipient sendTo = new EmailRecipient()
{
Address = "abc@outlook.com"
};
//generate mail object
EmailMessage mail = new EmailMessage();
mail.Subject = "Feedback";
//add recipients to the mail object
mail.To.Add(sendTo);
//mail.Bcc.Add(sendTo);
//mail.CC.Add(sendTo);
//open the share contract with Mail only:
await EmailManager.ShowComposeNewEmailAsync(mail);
我得到错误说:
"Error 1 'await'操作符只能在async方法中使用。考虑使用'async'修饰符标记此方法并进行更改它的返回类型为'Task'。"
您需要用async
关键字标记您的事件处理程序,以便能够在其中await
:
public async void MyButtonHandler(object sender, EventArgs e)
{
EmailRecipient sendTo = new EmailRecipient()
{
Address = "abc@outlook.com"
};
//generate mail object
EmailMessage mail = new EmailMessage();
mail.Subject = "Feedback";
//add recipients to the mail object
mail.To.Add(sendTo);
//mail.Bcc.Add(sendTo);
//mail.CC.Add(sendTo);
//open the share contract with Mail only:
await EmailManager.ShowComposeNewEmailAsync(mail);
}