Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  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:@"yourrecipent@domain.com"]];
  6.  
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement