想要在用户没有在邮件中实现任何邮件帐户的情况下在iphone中打开邮件设置

时间:2012-03-29 05:24:48

标签: iphone ipad mfmailcomposer

我已经实现了邮件编辑器。但只要用户在iphone中实现了邮件帐户,它就会打开邮件编写器。我的要求是如果用户没有实现邮件accont,则应该打开邮件设置。

1 个答案:

答案 0 :(得分:2)

试试这段代码......

      if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
               //open mail set up
            [self launchMailAppOnDevice];
        }

// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
    NSString *recipients = @"mailto:first@example.com?cc=second@example.com,third@example.com&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]];
}