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

Popular posts from this blog

Windows Keys

how to send invite and give a access of selected application on App Store

how to display popover in TableView cell in swift