YouTip LogoYouTip

Ios Sending Email

# iOS Sending Email * * * ## Introduction We can use the email application built into iOS devices to send emails. ### Steps for Example 1. Create a simple View-based application 2. Select the project file, then select the target, and add MessageUI.framework 3. Add a button in ViewController.xib and create an action (IBAction) for sending email 4. Update ViewController.h as follows ```objc #import #import @interface ViewController : UIViewController{ MFMailComposeViewController *mailComposer; } -(IBAction)sendMail:(id)sender; @end 5. Update ViewController.m as follows ```objc #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { ; } - (void)didReceiveMemoryWarning { ; // Dispose of any resources that can be recreated. } -(void)sendMail:(id)sender{ mailComposer = [init]; mailComposer.mailComposeDelegate = self; [mailComposer setSubject:@"Test mail"]; [mailComposer setMessageBody:@"Testing message for the test mail" isHTML:NO]; [self presentModalViewController:mailComposer animated:YES]; } #pragma mark - mail compose delegate -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{ if (result) { NSLog(@"Result : %d",result); } if (error) { NSLog(@"Error : %@",error); } [self dismissModalViewControllerAnimated:YES]; } @end ### Output When running this application, you will see the following output: ![Image 3: sendEmailOutput1](http://w)
← Ios Audio VideoIos Sqlite β†’