The simulator will crash when you try to open the mail. Try it on an actual device instead.
To compose a mail do the following Add these to your class MFMessageComposeViewControllerDelegate and MFMailComposeViewControllerDelegate
In your didSelectRowAtIndexPath, this is the function called when you presses a row in your tableView. Do the following:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { let candy = candies[indexPath.row] var mail: MFMailComposeViewController! // yourArray is the array that you use to populate the tableView // .mail is the variable in the object (I´m assuming you´re using objects in your array) let toRecipients = [candy[indexPath.row].email] let subject = "Feedback" let body = "<br><br><p>I have a \(UIDevice.currentDevice().modelName).<br> And iOS version \(UIDevice.currentDevice().systemVersion).<br</p>" mail = MFMailComposeViewController() mail.mailComposeDelegate = self mail.setToRecipients(toRecipients) mail.setSubject(subject) mail.setMessageBody(body, isHTML: true) presentViewController(mail, animated: true, completion: nil) }
The delegate methods below if you need to use them
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) { dismissViewControllerAnimated(true, completion: nil) } func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) { switch (result.rawValue) { case MessageComposeResultCancelled.rawValue: self.dismissViewControllerAnimated(true, completion: nil) case MessageComposeResultFailed.rawValue: self.dismissViewControllerAnimated(true, completion: nil) case MessageComposeResultSent.rawValue: self.dismissViewControllerAnimated(true, completion: nil) default: break; } }