通过电子邮件发送 UITextView 的内容
我的应用程序生成从文本字段到 uitextview 的信息,我想知道当用户单击按钮时如何通过电子邮件发送此信息。
邮件应用程序应该打开,并且电子邮件正文中将包含 uitextview 的内容。
非常感谢
My app generates information from textfields to a uitextview, i was wondering how i could send this information on a email when the user clicks a button.
The mail application should open and it will have the contents of the uitextview in the body of the email.
Many Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 MFMailComposeViewController 来完成此操作。代码如下:
只需将
@"My subject"
替换为您的真实主题,并将@"Email Body"
替换为 TextView 的内容。您还可以通过此类设置To
、Cc
和Bcc
字段并添加一些附件。您还可以使用以下方法检查应用是否可以发送电子邮件:
例如,如果用户没有配置其电子邮件帐户,则此函数将返回
NO
。有关从应用程序发送电子邮件的更多信息,您可以在 MFMailComposeViewController 类参考。
You have to do it with
MFMailComposeViewController
. Here's the code:Just replace
@"My Subject"
with your real subject and@"Email Body"
with your TextView's contents. You can also setTo
,Cc
andBcc
fields and add some attachments via this class.You can also check if app can send an email by using:
E.g. if user didn't configure his email accounts, this function will return
NO
.More info about sending emails from your app you can find in MFMailComposeViewController Class Reference.