在我的应用程序中,出于调试目的和测试目的,我需要发送电子邮件.
In my app, for debugging purposes and testing purposes I need to send an email.
当发送它的类不包含PresentViewController的定义时,如何显示邮件控制器?用户在激发的警报中单击是"后,该类需要激发电子邮件应用程序.
How do I present the mail controller, when the class that sends it does not contain a definition for PresentViewController ? The class needs to fire off the email app after the user clicks "yes" from the alert which fires.
public async Task<bool> SendEmail(Exception ex) { var result = await SendNotificationToRequestSendingEmail(); if (result) { if (MFMailComposeViewController.CanSendMail) { mailController = new MFMailComposeViewController(); mailController.SetToRecipients(new string[] { "test@one", "test@two" }); mailController.SetSubject("Details"); mailController.SetMessageBody($"Message: {ex.Message}" + $"Exception: {ex.ToString()}" , false); mailController.Finished += (object s, MFComposeResultEventArgs args) => { Console.WriteLine(args.Result.ToString()); args.Controller.DismissViewController(true, null); }; this.PresentViewController(mailController, true, null); //this line causes the error } } return true; }如何解决或解决此问题?这是从Xamarin表单页面调用的.
How can I fix this problem or get around it? This is called from a Xamarin Forms page.
推荐答案请查看以下答案:
从Gmail中发送电子邮件Xamarin.Forms应用程序
除此之外,您也可以使用此NuGet软件包来做到这一点:
besides that you can also do it with this NuGet package:
www.nuget/packages/Xam.Plugins.信息/
更多推荐
使用依赖关系服务从Xamarin.Forms应用发送电子邮件
发布评论