I'm trying to figure out why the email client does not always start when using what looks like a valid html formatted mailto URL.
The app I created genrates HTML text on the fly similar to the following but much more information:
NSString *body = @"<html><body><h4>Greeting</h4><table><tr><td><b>Hi There!</b></td><td>this and that</td></tr></body></html>";
At this point, no encoding has been done yet to any spaces, ampersands, etc.
Then I use the following to finish composing it and send it to the email client:
NSString *encoded_body = [body2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *subject = [@"test email" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *mail_string = [NSString stringWithFormat"mailto:?subject=%@&body=%@", subject, encoded_body];
NSURL *url = [[NSURL alloc] initWithString:mail_string];
[[UIApplication sharedApplication] openURL:url];
For most of the customers it seems to work, but for many, the openUrl command does nothing (i.e the app does not exit and the email client does not start).
When I test the customer situation, I can duplicate the issue, but looking at the html, I can't find anything wrong.
If I randomly just comment out some part of the html, then it works sometimes, so then I'll uncomment it and comment something else out, and it still works. So what I'm finding is that it's not a particluar piece of html this is bad, it seems that all I have to do is just comment out some part of the html and then it will work.
My theory is it's not being encodeded properly, and commenting out part of the html changes something to allow the encoding to work on what's left of the body.
Anyway experience similar problems?
Is there an obvious step I'm missing?
Thanks
The app I created genrates HTML text on the fly similar to the following but much more information:
NSString *body = @"<html><body><h4>Greeting</h4><table><tr><td><b>Hi There!</b></td><td>this and that</td></tr></body></html>";
At this point, no encoding has been done yet to any spaces, ampersands, etc.
Then I use the following to finish composing it and send it to the email client:
NSString *encoded_body = [body2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *subject = [@"test email" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *mail_string = [NSString stringWithFormat"mailto:?subject=%@&body=%@", subject, encoded_body];
NSURL *url = [[NSURL alloc] initWithString:mail_string];
[[UIApplication sharedApplication] openURL:url];
For most of the customers it seems to work, but for many, the openUrl command does nothing (i.e the app does not exit and the email client does not start).
When I test the customer situation, I can duplicate the issue, but looking at the html, I can't find anything wrong.
If I randomly just comment out some part of the html, then it works sometimes, so then I'll uncomment it and comment something else out, and it still works. So what I'm finding is that it's not a particluar piece of html this is bad, it seems that all I have to do is just comment out some part of the html and then it will work.
My theory is it's not being encodeded properly, and commenting out part of the html changes something to allow the encoding to work on what's left of the body.
Anyway experience similar problems?
Is there an obvious step I'm missing?
Thanks