I have got a strange issue , the below code works fine in IOS5 device , all simulators , but fails in IOS6 Device.I am getting a blank view in place of image.
Requirement : Need to add the image in mail.
NSString *imageName = @"classroom_tile.png";
imagePath = [[NSBundle mainBundle]bundlePath];
imagePath = [imagePath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",imageName]];
imagePath = [@"file:///" stringByAppendingString:imagePath];
NSString *formatedUrl = [NSString stringWithFormat:@"</br><table border =\"0\"><tr><td></td><th>%@</th></tr><tr><td><img src= \'%@\' width=200 height=150></td></tr></table>",sometext,imagePath];
[mailComposer setMessageBody:formatedUrl isHTML:YES];
Please do suggest.
Thanks and Regards,
Anil
What you are trying to do has never been supported. The only valid way to get an image into an email is to add the image as an attachment. But even then you can’t reference the image attachment in the mail message body.
What works in the simulator is irrelevant for something like this since you can’t actually send the email in the simulator. Let me ask this – when running this on an iOS 5 device, does the received email sent from the app actually show the image or does it only appear correctly in the mail composer in the app? I’d be quite surprised if such an email sent from the app and opened in some email client on a user’s computer showed the image.
Edit: It turns out this really did work under iOS 5 but doesn’t under iOS 6. I’m quite surprised. I did my own quick test. Under iOS 5.1 sending an email with such an image reference to a local file on the iOS device actually does get sent along with the email and does appear in the client email program on their computer. When the app is run under iOS 6, the image does not appear in the mail composer in the app nor in the received email. So at least that is consistent.
One other little side note. This line:
should be:
Don’t use
stringWithFormat:unless you are actually using a string format. Also, there is no need to create the extraNSStringobject.Also, here’s a better way to get the path to a file in your resource bundle:
That one line would replace the first three lines you posted.
One last note. When using an HTML email message, include the
<html>and<body>tags.