मूल अमित के जवाब की स्विफ्ट संस्करण:
स्विफ्ट 2:
func openMailApp() {
let toEmail = "[email protected]"
let subject = "Test email".stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet()
let body = "Just testing ...".stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet()
if let
urlString = ("mailto:\(toEmail)?subject=\(subject)&body=\(body)")),
url = NSURL(string:urlString) {
UIApplication.sharedApplication().openURL(url)
}
}
स्विफ्ट 3.0:
func openMailApp() {
let toEmail = "[email protected]"
let subject = "Test email".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
let body = "Just testing ...".addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)
if let
urlString = "mailto:\(toEmail)?subject=\(subject)&body=\(body)",
url = URL(string:urlString) {
UIApplication.shared().openURL(url)
}
}
का उपयोग करके लिखें दृश्य खोलकर का उपयोग किए बिना मेल एप्लिकेशन खोल सकता है? – Novarg