使用依赖关系服务从Xamarin.Forms应用发送电子邮件

编程入门 行业动态 更新时间:2024-10-28 04:19:02
本文介绍了使用依赖关系服务从Xamarin.Forms应用发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序中,出于调试目的和测试目的,我需要发送电子邮件.

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应用发送电子邮件

本文发布于:2023-10-07 10:22:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送电子邮件   关系   Xamarin   Forms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!