If you want to open the embedded email application, rather than displaying MFMailComposeViewController , as others have mentioned, you can build the mailto: link as follows:
let subject = "My subject" let body = "The awesome body of my email." let encodedParams = "subject=\(subject)&body=\(body)".stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet()) let url = "mailto: foo@bar.com ?\(encodedParams)" if let emailURL = NSURL(url) { if UIApplication.sharedApplication().canOpenURL(emailURL) { UIApplication.sharedApplication().openURL(emailURL) } }
Just to save someone typing, in 2016 the syntax changed slightly:
let subject = "Some subject" let body = "Plenty of email body." let coded = "mailto: blah@blah.com ?subject=\(subject)&body=\(body)".stringByAddingPercentEncodingWithAllowedCharacters(.URLQueryAllowedCharacterSet()) if let emailURL:NSURL = NSURL(string: coded!) { if UIApplication.sharedApplication().canOpenURL(emailURL) { UIApplication.sharedApplication().openURL(emailURL) }
source share