通过电子邮件发送 UITextView 的内容

发布于 2024-12-15 04:41:06 字数 124 浏览 3 评论 0原文

我的应用程序生成从文本字段到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩发小公举 2024-12-22 04:41:06

您必须使用 MFMailComposeViewController 来完成此操作。代码如下:

MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];

[composer setMailComposeDelegate:self];
[composer setSubject:@"My Subject"];
[composer setMessageBody:@"Email Body" isHTML:YES];

[self presentModalViewController:composer animated:YES];

[composer release];

只需将 @"My subject" 替换为您的真实主题,并将 @"Email Body" 替换为 TextView 的内容。您还可以通过此类设置ToCcBcc字段并添加一些附件。

您还可以使用以下方法检查应用是否可以发送电子邮件:

[MFMailComposeViewController canSendMail];

例如,如果用户没有配置其电子邮件帐户,则此函数将返回NO


有关从应用程序发送电子邮件的更多信息,您可以在 MFMailComposeViewController 类参考

You have to do it with MFMailComposeViewController. Here's the code:

MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];

[composer setMailComposeDelegate:self];
[composer setSubject:@"My Subject"];
[composer setMessageBody:@"Email Body" isHTML:YES];

[self presentModalViewController:composer animated:YES];

[composer release];

Just replace @"My Subject" with your real subject and @"Email Body" with your TextView's contents. You can also set To, Cc and Bcc fields and add some attachments via this class.

You can also check if app can send an email by using:

[MFMailComposeViewController canSendMail];

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文