IPhone - Anyway to get the iPhone email app in its own app?

Has anyone put an iPhone Email program into your own app?

Let me try and simplify this. Tap Tap Revenge allows you to "challenge a friend". When you decide to do this, they'll open the standard iPhone email program (if they mimic it, it looks pretty damn good), in a pre-populated app. All you have to do is select a friend from your contacts and hit send. You never leave the Tap Tap Revenge app.

Any ideas how this is done?

+2


source to share


4 answers


You need to include MessageUI.framework

in your project and inside your header file you need to set the delegate:

#import <MessageUI/MessageUI.h>
@interface RootViewController : UIViewController <MFMailComposeViewControllerDelegate> {
    MFMailComposeViewController *email;
}

@property (nonatomic, retain) MFMailComposeViewController *email;

      

Once you've done that, you have several delegation methods inside your implementation file that you need to include (you should check to see the result, but I try to keep as little code as possible):



@synthesize email;

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [email dismissModalViewControllerAnimated:YES];
} 

      

If you want to use this, you need to initialize and configure it like this:

email = [[MFMailComposeViewController alloc] init];
email.mailComposeDelegate = self;

// Subject
[email setSubject:@"Testing"];

// Optional Attachments
NSData *artwork = UIImagePNGRepresentation([UIImage imageNamed:@"albumart.png"]);
[email addAttachmentData:artwork mimeType:@"image/png" fileName:@"albumart.png"];

// Body
[email setMessageBody:@"This is the body"];

// Present it
[self presentModalViewController:email animated:YES];

      

+5


source


In addition to Garett's great response, you should receive a warning:

'MFMailComposeViewController' may not respond to '-setMessageBody:'



add isHTML: so the full line reads like this:

[mail setMessageBody: @ "This body" isHTML: NO];

+3


source


There are two answers for this. For apps that need to support iPhone OS up to 3.0, the only way is to create your own message composer. Or you might want to take a look at the component created by Joe Hewitt, who wrote the Facebook iPhone app.

http://github.com/joehewitt/three20/blob/master/src/Three20/TTMessageController.h

With the iPhone SDK 3.0, you can use the Mail message composer interface directly if the mailbox uses MessageUI.framework

as described above.

0


source


messagecomposer is the way to go! mail and sms inside the application, run iOS 3.1. need sdk 4

0


source







All Articles