Chapter 6
Working with Email and Attachments
The MessageUI
framework has made it really easy to send an email from your apps. You can easily use the built-in APIs to integrate an email composer in your app. In this short chapter, we'll show you how to send emails and work with email attachments by creating a simple app.
Since the primary focus is to demonstrate the email feature of the MessageUI
framework, we will keep the demo app very simple. The app simply displays a list of files in a plain table view. We'll populate the table with various types of files, including images in both PNG and JPEG formats, a Microsoft Word document, a Powerpoint file, a PDF document, and an HTML file. Whenever users tap on any of the files, the app automatically creates an email with the selected file as an attachment.
Starting with the Xcode Project Template
To save you from creating the Xcode project from scratch, you can download the project template from http://www.appcoda.com/resources/swift55/EmailAttachmentStarter.zip to begin the development. The project template comes with:
- a pre-built storyboard with a table view controller for displaying the list of files
- an AttachmentTableViewController class
- a set of files that are used as attachments
- a set of free icons from Pixeden (http://www.pixeden.com/media-icons/flat-design-icons-set-vol1)
After downloading and extracting the zipped file, you can compile and run the project. The demo app should display a list of files on the main screen. Now, we'll continue to implement the email feature.
To continue reading and access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.