Search code examples
iphoneobjective-cemailtextviewmfmailcomposeviewcontroller

How do I send the contents of a textView as an Email?


I have an app that has favorite quotes that are displayed using a textView. I want to provide the option of emailing directly from this textView. Secondly I would like to be able export to a PDF or Pages document, which I can then email out. Is there any way to do this?


Solution

  • place a UIButton along the textView and send email like this

    -(void)sendEmail 
    
    {
     
    
     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
     picker.mailComposeDelegate = self;
     
     [picker setSubject:urSubject];
     
      NSString *emailBody =
     [NSString stringWithString:urTextView.text];
     
     [picker setMessageBody:emailBody isHTML:NO];  
     
     [self presentModalViewController:picker animated:YES];
     [picker release];
     
    }