1

I am trying to send an email with an embed code (html snippet) but the email body is empty.

        NSURL *url = [NSURL URLWithString: me.emailUrl];
        [[UIApplication sharedApplication] openURL:url];

        NSLog(@"SnapShotViewController->infoAction: %@", url);

The original string looks like this.

<iframe style='width:320px;height:320px;border:0px' src='http://snapserve.alphakanal.de/embed?key=b500bb47-e14d-405f-a70b-9779dbb8ce21'>

The final string looks like this.

mailto:?subject=SnapShot&body=%3Ciframe%20style%3D'width:320px;height:320px;border:0px'%20src%3D'http://snapserve.alphakanal.de/embed%3Fkey%3Db500bb47-e14d-405f-a70b-9779dbb8ce21'%3E%3C/iframe%3E

The email app opens up but does not show the body. Any idea?

loopmasta
  • 1,693
  • 3
  • 14
  • 19

1 Answers1

0

Use - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding on your NSString containing the HTML, like so:

NSString *html = @"<html><body><b>test</b></body></html>";
NSString *email = [NSString stringWithFormat:@"mailto:?subject=SnapShot&body=%@",[html stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
Sascha
  • 5,903
  • 3
  • 24
  • 20
  • Thats exactly what i am doing. See the final string in my first post. Thats the output of stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding. But the email is still blank. – loopmasta May 30 '11 at 23:44
  • Well, http://snapserve.alphakanal.de/embed?key=b500bb47-e14d-405f-a70b-9779dbb8ce21 is blank. So what exactly do you expect? – Sascha May 30 '11 at 23:49
  • It is not blank. It returns a valid html page. But thats not what i wanted to show in the email. The user should see the actual – loopmasta May 31 '11 at 06:36