swift email composer
import Foundation
import MessageUI
import UIKit
class emailClass: UIViewController, MFMailComposeViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
if !MFMailComposeViewController.canSendMail() {
print("Mail services are not available")
return
}
sendEmail()
}
func sendEmail() {
let composeVC = MFMailComposeViewController()
composeVC.mailComposeDelegate = self
// Configure the fields of the interface.
composeVC.setToRecipients(["[email protected]"])
composeVC.setSubject("Hello!")
composeVC.setMessageBody("Hello this is my message body!", isHTML: false)
// Present the view controller modally.
self.present(composeVC, animated: true, completion: nil)
}
func mailComposeController(controller: MFMailComposeViewController,
didFinishWithResult result: MFMailComposeResult, error: NSError?) {
// Check the result or perform other tasks.
// Dismiss the mail compose view controller.
controller.dismiss(animated: true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Also in Swift:
- run a function only once swift
- swift how to sort array
- add buton border swift
- swift hide navigation bar
- index string swift
- swift VStack
- hide status bar ios
- swift push view controller
- Failure Reason: SecurityUser Info: {DVTRadarComponentKey = 855031;RawLLDBErrorMessage = Security
- alertdialog flutter
- Resizing UITableView to fit content
- swift get day from available string
- swift 5 only the day number from date
- get files with file type swift
- swift collection view check if you are at the bottom
- how to get index path cell collection view from ui longpress gesture swift
- get difference between two arrays swift
- disable commit editing style swift
- array length swift
- swift get device screen size
- disable swipe to delete swift
- navigationviewcontroller setviewcontrollers swift
- UI API called on a background thread
- how to know when text changed textfield swiftui