Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let email = "feedback@company.com"
- let subject = "subject"
- let bodyText = "Please provide information that will help us to serve you better"
- if MFMailComposeViewController.canSendMail() {
- let mailComposerVC = MFMailComposeViewController()
- mailComposerVC.mailComposeDelegate = self
- mailComposerVC.setToRecipients([email])
- mailComposerVC.setSubject(subject)
- mailComposerVC.setMessageBody(bodyText, isHTML: true)
- self.present(mailComposerVC, animated: true, completion: nil)
- } else {
- let coded = "mailto:\(email)?subject=\(subject)&body=\(bodyText)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
- if let emailURL = URL(string: coded!)
- {
- if UIApplication.shared.canOpenURL(emailURL)
- {
- UIApplication.shared.open(emailURL, options: [:], completionHandler: { (result) in
- if !result {
- // show some Toast or error alert
- //("Your device is not currently configured to send mail.")
- }
- })
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement