Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jim mason

macrumors newbie
Original poster
Sep 24, 2017
3
1
Hi guys
I am very new to swift, and have created a very basic app but I am stuck on coding it and cannot find the answer in Xcode help files
Basicly there is a submit button and a text box were you enter vehicle registration, what I need to code is when submit button pressed it sends whatever registration is in the text box to my email address, can anyone point me in the right direction to code this
Many thanks.
 
Couple of different ways, you can code it so it opens a new email in the mail client on the device (however not everyone has Mail set up on their device).

The better way of doing it is to create a web service which you 'post' to on submit that will send the email for you.

For example, you can use something like send grid as a webservice (https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html) and create a url request when you press the button on the screen to post the data to SendGrids web api to send the email on your behalf.
 
As mds1256 mentioned, you could open a mail window and populate with the information. For that look up MFMailComposeViewController and its delegate. There is NOT an option to hide the window and send the email in the back ground. I suppose there could be a third party library that could send a hidden email.

That leaves setting up a server that your app can communicate with.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.