我的应用程序发送了一封包含图像的电子邮件,但电子邮件中没有图像。
我创建了一个HTML字符串,并在电子邮件中将其作为正文发送。但在设备上执行此操作时,电子邮件中没有任何内容。在模拟器里也没问题。我把一个WebView放在我的应用程序里,然后把它放进去,它就会显示所有的图片。
有人知道问题出在哪里吗?
发布于 2013-01-11 21:31:33
这是我用来在邮件正文中附加图片的代码
NSMutableString *htmlBody = [[NSMutableString alloc] initWithString:@"<html><body>"];
[htmlBody appendString:@"<p>Enter Text Here</p>"];
UIImage *emailImage = [UIImage imageNamed:@"image.png"];
NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(emailImage)];
NSString *base64String = [imageData base64EncodedString];
[htmlBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'> </b></p>",base64String]];
[htmlBody appendString:@"</body></html>"];
NSLog(@"%@",htmlBody);
[mailComposer htmlBody isHTML:YES];希望它能帮助你..
https://stackoverflow.com/questions/14279133
复制相似问题