Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I launch an email client on ios using Swfit

Tags:

ios

swift

In Android, I can launch an email client from my android application using its Intent mechanism. In ios, how can I launch its email client from my ios application using Swift?

Thank you.

like image 226
hap497 Avatar asked Sep 26 '14 05:09

hap497


People also ask

How do I open the email app in iOS Swift?

Show activity on this post. let email = "[email protected]" let url = URL(string: "mailto:\(email)") UIApplication. shared. openURL(url!)

What protocol does iOS Mail use?

The current version of Apple Mail utilizes SMTP for message sending, POP3, Exchange and IMAP for message retrieval and S/MIME for end-to-end message encryption.


2 Answers

Updated for Xcode 12.5

let url = NSURL(string: "mailto:mailto:[email protected]")
                                                UIApplication.shared.open(url! as URL)

or if you would like to add an embedded subject

let url = NSURL(string: "mailto:[email protected]?subject=This%20is%20the%20subject&[email protected]&body=This%20is%20the%20body")

or if you want to add multiple email addresses

let url = NSURL(string: "mailto:mailto:[email protected],[email protected]")
                                                    UIApplication.shared.open(url! as URL)


                                                
like image 76
flutterloop Avatar answered Sep 29 '22 11:09

flutterloop


let url = NSURL(string: "mailto:[email protected]")
UIApplication.sharedApplication().openURL(url)

Note that this works only on a device, not in the simulator.

like image 32
Mundi Avatar answered Sep 29 '22 12:09

Mundi