-1

I have implemented mail composer. But it opens mail composer whenever user had implemented mail account in iphone. My requirement is If user had not implemented mail accont , the mail setup should be opened.

iamsult
  • 1,581
  • 1
  • 15
  • 21
DipakSonara
  • 2,598
  • 3
  • 29
  • 34

1 Answers1

2

Try this code...

      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]];
}
Raj Subbiah
  • 1,292
  • 11
  • 20