如何将 UITextField 或 UITextView 的文本导出到电子邮件?

How to export UITextField or UITextView's text to email?

假设我有 myTextField.text = @"hello world";.

如何将其保存到 .txt 文件,然后通过电子邮件附件发送?

看看这个post:Send a file as attachment in objective c

在您的情况下,显示 sheet 类似于:

-(void)displayComposerSheet 
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:@"Check out this image!"];
    // Attach the text field content to the email
    UIImage *coolImage = ...;
    NSData *myData = UIImagePNGRepresentation(coolImage);
    NSData* data = [myTextField.text dataUsingEncoding:NSUTF8StringEncoding];
    [picker addAttachmentData:data mimeType:@"text/plain" fileName:@"myText.txt"];

    // Fill out the email body text
    NSString *emailBody = @"My text is attached";
    [picker setMessageBody:emailBody isHTML:NO];
    [self presentModalViewController:picker animated:YES];
}

更多信息在这里:https://developer.apple.com/library/ios/documentation/MessageUI/Reference/MFMailComposeViewController_class/#//apple_ref/occ/instm/MFMailComposeViewController/addAttachmentData:mimeType:fileName: