Email Sending in swift(ios)
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate
{
override func viewDidLoad()
{
super.viewDidLoad()
sendEmail()
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
}
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)
}
}
Comments
Post a Comment