Reputation: 113
I want a view controller to only contain a text field and a send button. Is there a way to get the button to send the contents of the text field to a preset email address? Or is the only email capability MFMailComposeViewController
?
Upvotes: 0
Views: 1873
Reputation: 38833
You can only send a mail through the MFMailComposeViewController
, but you could pass the value from your text field like the example below.
Place this code in your buttons action:
let toRecipients = ["[email protected]"]
let subject = "My Subject"
let body = textField.text // Your text fields text
mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setToRecipients(toRecipients)
mail.setSubject(subject)
mail.setMessageBody(body, isHTML: false)
presentViewController(mail, animated: true, completion: nil)
Upvotes: 1