forked from burczyk/XcodeSwiftSnippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMFMailComposeViewController.swift
27 lines (20 loc) · 1.24 KB
/
MFMailComposeViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//MARK: MFMailComposeViewController
func presentModalMailComposeViewController(animated: Bool) {
if MFMailComposeViewController.canSendMail() {
let mailComposeVC = MFMailComposeViewController()
mailComposeVC.delegate = self
mailComposeVC.setSubject(<#subject#>)
mailComposeVC.setMessageBody(<#body#>, isHTML: true)
mailComposeVC.setToRecipients([<#recipients#>])
presentViewController(mailComposeVC, animated: animated, completion: nil)
} else {
UIAlertView(title: NSLocalizedString("Error", value: "Error", comment: ""), message: NSLocalizedString("Your device doesn't support Mail messaging", value: "Your device doesn't support Mail messaging", comment: ""), delegate: nil, cancelButtonTitle: NSLocalizedString("OK", value: "OK", comment: "")).show()
}
}
//MARK: MFMailComposeViewControllerDelegate
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) {
if error != nil {
println("Error: \(error)")
}
dismissViewControllerAnimated(true, completion: nil)
}