Last active
October 17, 2015 06:00
-
-
Save soggybag/ed9b0ad90ca0937aac62 to your computer and use it in GitHub Desktop.
Send Email with Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import MessageUI | |
class ViewController: UIViewController, MFMailComposeViewControllerDelegate { | |
func sendEmail() { | |
let mailVC = MFMailComposeViewController() | |
mailVC.mailComposeDelegate = self | |
mailVC.setToRecipients([]) | |
mailVC.setSubject("Subject for email") | |
mailVC.setMessageBody("Email message string", isHTML: false) | |
presentViewController(mailVC, animated: true, completion: nil) | |
} | |
// MARK: - Email Delegate | |
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) { | |
controller.dismissViewControllerAnimated(true, completion: nil) | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment