Search code examples
iosobjective-cxcodeemail-attachmentsmfmailcomposeviewcontroller

MFMailComposeViewController few attachments


I'm successfully sending an email with attached UIImage from my app, but is it possible to attach more than one image with MFMailComposeViewController ?


Solution

  • you can save all the images in an NSMutable array and run the code

    [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@""];
    

    for the count of your NSMutableArray. It will add the images to attachment field

      for (int i = 0; i < [_textField0.emojiArray count]; i++)         
     {
        emoji = [_textField0.emojiArray objectAtIndex:i];
      UIImage *image = [EmojiResizer resizeImage2:[UIImage imageNamed:emoji.screenfilename]
       imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
    
     [mailViewController addAttachmentData:imageData mimeType:@"image/png" fileName:emoji.filename];         
    }
    

    Do something like this.