Launch Apple Mail App from within my own App?

后端 未结 15 2311
心在旅途
心在旅途 2020-11-29 01:59

What I already found is

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

But I just want to open the Mail ap

15条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 02:12

    Expanding on Amit's answer: This will launch the mail app, with a new email started. Just edit the strings to change how the new email begins.

    //put email info here:
    NSString *toEmail=@"supp0rt.fl0ppyw0rm@gmail.com";
    NSString *subject=@"The subject!";
    NSString *body = @"It is raining in sunny California!";
    
    //opens mail app with new email started
    NSString *email = [NSString stringWithFormat:@"mailto:%@?subject=%@&body=%@", toEmail,subject,body];
    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
    

提交回复
热议问题