Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch Apple Mail App from within my own App?

Tags:

email

ios

What I already found is

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:"]]; 

But I just want to open the Mail app not only a composer view. Just the mail app in its normal or last state.

Any ideas?

like image 602
cschuff Avatar asked Jan 11 '12 15:01

cschuff


2 Answers

Apparently Mail application supports 2nd url scheme - message:// which ( I suppose) allows to open specific message if it was fetched by the application. If you do not provide message url it will just open mail application:

NSURL* mailURL = [NSURL URLWithString:@"message://"]; if ([[UIApplication sharedApplication] canOpenURL:mailURL]) {     [[UIApplication sharedApplication] openURL:mailURL]; } 
like image 172
Vladimir Avatar answered Sep 21 '22 09:09

Vladimir


NSString *recipients = @"mailto:[email protected][email protected],[email protected]&subject=Hello from California!";  NSString *body = @"&body=It is raining in sunny California!";  NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];  email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]]; 
like image 25
Amit Avatar answered Sep 23 '22 09:09

Amit