6

For my app, I need to know if there's a mail account has soon as the app is launched. Is there a way to do that ?

I don't really know what canSendMail does but it does not seems to verify that.

Thanks

little
  • 61
  • 1
  • 2
  • Why exactly doesn't `canSendMail` (`MFMailComposeViewController`) work for you? As far as I'm aware, that's the only option you have. – omz Aug 07 '11 at 17:35
  • Well I tested it on the simulator and it was always returning true. But you're right, on the device it does what I want – little Aug 07 '11 at 18:07
  • ya with canSendMail you can check for the availability of wheater the account is configured or not .. – abhi.shah88 Aug 07 '11 at 18:09
  • 1
    I'm surprised that the documentation doesn't seem to mention this. The simulator will always return `YES`, because it can pretend to send mail, even though you can't actually create an email account there. It makes testing easier. – omz Aug 07 '11 at 18:12

2 Answers2

28

canSendMail is actually the right and only way to verify what you want.

if ([MFMailComposeViewController canSendMail]) {
    // device is configured to send mail
}
Filip Radelic
  • 26,607
  • 8
  • 71
  • 97
0

For those looking for a Xamarin solution it is available as a static property, so you can do it something like this:

MFMailComposeViewController.CanSendMail
FreakyAli
  • 13,349
  • 3
  • 23
  • 63