我有一些带有几个文本框和标签的视图。我想将包含此信息的视图通过电子邮件发送到联系人列表或仅包含电子邮件地址的文本框。
我无法查看电子邮件。我想发送整个页面,而不必以某种方式列出每个文本框。如何使用以下代码通过电子邮件发送视图:
[controller setMessageBody:textBoxesAndInfo isHTML:YES];
答案 0 :(得分:6)
-(IBAction)sendMail {
// create an instance of MFMailComposeViewController for sending an e-mail
MFMailComposeViewController *controller =
[[MFMailComposeViewController alloc] init];
// set controller's delegate to this object
controller.mailComposeDelegate = self;
[controller setToRecipients:@[@"hello@example.com"]];
[controller setSubject:@"Subject"];
[controller setMessageBody:textBoxesAndInfo isHTML:YES];
// show the MFMailComposeViewController
[self presentModalViewController:controller animated:YES];
}
// called when the user finishes sending an e-mail
- (void)mailComposeController:(MFMailComposeViewController*)controller
didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissModalViewControllerAnimated:YES];
}
请记住包含MessageUI框架。