The MFMailComposeViewController class gives you the view you want.
The disadvantage for what you want is that you can access from that view to some emails available in CoreData, since from this view you only access the emails in your calendar.
A possible solution would be that you first create a view in which you access that list of emails and you can select them, and then present MFMailComposeViewController with the emails already chosen.
import MessageUI
class vistaCorreos: UIViewController, MFMailComposeViewControllerDelegate {
var arrayCorreos : [String] = []
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func sendEmail(_ sender: UIButton) {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients(arrayCorreos)
mailComposerVC.setSubject("") //Puedes predeterminar un asunto o dejarlo vacío
mailComposerVC.setMessageBody("", isHTML: false)
self.present(mailComposerVC, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Aquí puedes comprobar si se ha enviado o no y cerrar al terminar
controller.dismiss(animated: true, completion: nil)
}
Here you can find the
apple documentation