在这里只需用你的 Arr 调用这个函数
-(NSMutableString)createImgMailBodyFromArray:(NSMutableArray *)arr{
//Create a string with HTML formatting for the email body
NSMutableString *emailBody = [[NSMutableString alloc] initWithString:@"<html><body>"];
for (int i = 0; i<[arr count]; i++) {
UIImage *emailImage = [arr objectAtIndex:i];
//Convert the image into data
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
//Create a base64 string representation of the data using NSData+Base64
NSString *base64String = [imageData base64EncodedString];
//Add the encoded string to the emailBody string
//Don't forget the "<b>" tags are required, the "<p>" tags are optional
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",base64String]];
}
return emailBody;
}
现在就这样称呼
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *composeViewController = [[MFMailComposeViewController alloc] initWithNibName:nil bundle:nil];
[composeViewController setMailComposeDelegate:self];
[composeViewController setToRecipients:@[@"example@email.com"]];
[composeViewController setSubject:@"example subject"];
[composeViewController setMessageBody:[self createImgMailBodyFromArray:YOUR_ARR] isHTML:NO];
[self presentViewController:composeViewController animated:YES completion:nil];
}
而“NSData+base64”文件在这里你可以找到https://github.com/l4u/NSData-Base64