a guest Feb 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
  2. [mailController setMailComposeDelegate:self];
  3. [mailController setSubject:@"Mail Subject!"];
  4. [mailController setMessageBody:@"Here is your message body" isHTML:NO];
  5. [mailController setToRecipients:[NSArray arrayWithObject:@""]];
  7. NSData *imageData = UIImageJPEGRepresentation(imageToUpload, 1.0f);
  8. if(imageData.length)
  9. {
  10.     [mailController addAttachmentData:imageData mimeType:@"image/jpeg" fileName:@"Your_Photo.jpg"];
  11.     [self presentModalViewController:mailController animated:YES];
  12. }
  13. else
  14. {
  15.     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Invalid Image" message:@"The image couldn't be converted." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Okay", nil];
  16.     [alert show];
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand