1

I'm trying to open iOS's mail application by clicking a button.

So I did this :

NSString *mailString = [NSString stringWithFormat:@"mailto://test@test.com"];   
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailString]];

But nothing in particular happens... what's the problem ?

Thanks for your advices

Rob
  • 15,732
  • 22
  • 69
  • 107
  • Here is a very good explanation for this: http://stackoverflow.com/questions/310946/how-can-i-send-mail-from-an-iphone-application/1513433#1513433 – Arne Mar 23 '13 at 16:34

2 Answers2

3
@"mailto:test@test.com"

instead of

@"mailto://test@test.com"

Better way of doing this would be to use MFMailComposeViewController

Community
  • 1
  • 1
JoeCortopassi
  • 5,083
  • 7
  • 37
  • 65
  • 1
    Thanks for the advice. I just realized that I don't have Mail app in my Simulator... is it normal ? – Rob Jun 11 '12 at 22:31
  • 1
    @RobinDreux, yes, that is normal. Also, you shouldn't use stringWithFormat unless you are actually using a format string. I would imagine that your compiler is giving you a warning. – sosborn Jun 12 '12 at 00:31
0

And it works only on the real device, not on the simulator (in my case)

Maciek Czarnik
  • 5,950
  • 2
  • 37
  • 50