Using the Mail Composition Interface IPHONE APPS

In iPhone OS 3.0 and later, you can use the MF Mail Compose View Controller class to present a standard mail composition interface inside your own applications. Prior to displaying the interface, you use the methods of the class to configure the email recipients, the subject, body, and any attachments you want to include. Upon posting the interface (using the standard view controller techniques), the user has the option of editing the email contents before submitting the email to the Mail application for delivery. The user also has the right to cancel the email altogether.

To use the mail composition interface, you must add MessageUI. framework to your Xcode project and link against it in any relevant targets. To access the classes and headers of the framework, include an #import <Message UI/MessageUI.h> statement at the top of any relevant source files.

To use the MF Mail Compose View Controller class in your application, you create an instance and use its methods to set the initial email data. You must also assign an object to the mail Compose Delegate property of the view controller to handle the dismissal of the interface when the user accepts or cancels the email. The delegate object you specify must conform to the MF Mail Compose View Controller Delegate protocol.

When specifying email addresses for the mail composition interface, you specify plain string objects. If you want to use email addresses from the user’s list of contacts, you can use the Address Book framework to retrieve that information.

Listing shows the code for creating the MF Mail Compose View Controller object and displaying the mail composition interface modally in your application. You would include the display Composer Sheet method in one of your custom view controllers and call the method as needed to display the interface. In this example, the parent view controller assigns itself as the delegate and implements the mail Compose Controller: did Finish With Result: error: method. The delegate method dismisses the delegate without taking any further actions. In your own application, you could use the delegate to track whether the user sent or canceled the email by examining the value in the result parameter.

Posting the mail composition interface

@implementation WriteMyMailViewController (MailMethods)

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status