I am using NSSharingService to prepare an email with attachment for the user of my macOS app. My code is:

let emailService = NSSharingService.init(named: NSSharingService.Name.composeEmail)

if emailService.canPerform(withItems: [emailBody, zipFileURL]) {
   // email can be sent
   DispatchQueue.main.async {
       emailService.perform(withItems: [emailBody, zipFileURL])
   }
} else {
      // email cannot be sent
      // Show alert with email address and instructions
      self.showErrorAlert(with: 2803)
}

This works correctly, but if the code is executed on a fresh system, Apple Mail will be opened asking the user to configure an email account. Some users may not understand what is going on in this situation. Is there a way to ascertain if the default Email Client is configured, so that I can inform the user if it is not ? Thanks for your help.

0

There are 0 answers