Thursday 18 August 2011

Sending Email Through iPhone Within the app



Hi All,

This Blog describes how to send the e-mail from the app.

Very First you have to attach "MessageUI" framework kit in your framework folder.

In your ViewController.h file import this class:-

#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>



In your ViewController.m file write the below code:-


if([MFMailComposeViewController canSendMail]){

MFMailComposeViewController *mail=[[MFMailComposeViewController alloc]init];
mail.mailComposeDelegate=self;
[mail setSubject:@"subject of the mail"];
[mail setMessageBody:@"Hello my first mail from iphone app" isHTML:NO];
[self presentModalViewController:mail animated:YES];
[mail release];
}

- (void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
[self dismissModalViewControllerAnimated:YES];

}

No comments:

Post a Comment