-1

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

4

1 回答 1

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]];
}
于 2012-03-29T05:59:55.873 回答