I generate a html string who contains base64 images. When the MFMailComposeViewController open, I see the images in the generated email. When I send it and open it, the images are not displayed, there are just empty square.
My code
- (IBAction)actionShareByEmail:(id)sender {
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString* subject = @"Environments list with qrcode";
[picker setSubject:subject];
[picker setMessageBody:[manager getHtmlWithEnvironments:nil] isHTML:YES];
[self presentViewController:picker animated:YES completion:nil];
}
}
-(NSString*)getHtmlWithEnvironments:(NSArray*)envDictionnaries{
NSMutableString* html = [[NSMutableString alloc]init];
[html appendString: @"<html><body>"];
for (NSDictionary *d in self.arEnvironments) {
UIImage* qrcode = [QRCodeGenerator qrImageForString:[d objectForKey:@"env_name"] imageSize:200.0];//Works fine
NSData *imageData = UIImagePNGRepresentation(qrcode);
NSString *encodedString = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
[html appendString: [NSString stringWithFormat:@"<H3>%@</h3><img src=\"data:image/png;base64,%@\" width=\"200\" height=\"200\" alt=\"test\" /></br></br>",[d objectForKey:KEY_ENV_NAME],encodedString]];
}
[html appendString: @"</html><body>"];
return html;
}
How can I do to display images correctly ?
It looks like support for inline images is low - mainly due to security issues.
The link to Campaign Monitor in the second question below gives more information.
More Information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With