SENDING E-MAIL

Sending e-mail is one of the many tasks performed by iPhone users. Sending e-mail onthe iPhone is accomplished using the built-in Mail application, which is a rich HTML mail client that supports POP3, IMAP, and Exchange e-mail systems, and most web-based e-mail such as Yahoo! and Gmail.

There are times where you need to allow your user to send an e-mail message in your iPhone application. A good example is embedding a feedback button in your application that users canclick to send feedback to you directly. You have two ways to send e-mail programmatically:

  • Build your own e-mail client and implement all the necessary protocols necessary to communicate with an e-mail server.
  • Invoke the built-in Mail application and ask it to send the e-mail for you.

Unless you are well versed in network communications and familiar with all the e-mail protocols, your most logical choice is the second option — invoke the Mail application to do the job. The following Try It Out shows you how.

TRY IT OUT: Sending E-Mail Using the Mail Application

image

  1. Using Xcode, create a Single View Application (iPhone) project and name it Emails. You need to also use the project name as the Class Prefix and ensure that you have the Use Automatic ReferenceCounting option unchecked.
  2. Select the EmailsViewController.xib file to edit it in Interface Builder. Populate the View window with the following views(see ...

Get Beginning iOS 5 Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.