Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to send email in iphone SDK?

Tags:

iphone

how to send email in iphone SDK? any example tutorial to take email address from iphone also?

like image 445
senthil Avatar asked Oct 03 '09 09:10

senthil


People also ask

What is MessageUI?

The Message UI framework provides specialized view controllers for presenting standard composition interfaces for email and SMS (Short Messaging Service) text messages. Use these interfaces to add message delivery capabilities, without requiring the user to leave your app.

How do I download iOS SDK?

You can install the iOS SDK using CocoaPods or by manually downloading and installing it. We recommended that you use CocoaPods to install the iOS SDK because it handles the dependencies, the build settings, and simplifies upgrading.


1 Answers

You should use the MFMailComposeViewController class, and the MFMailComposeViewControllerDelegate protocol, that that tucked away in the MessageUI framework.

First to send a message:

MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:@"My Subject"];
[controller setMessageBody:@"Hello there." isHTML:NO]; 
[self presentModalViewController:controller animated:YES];
[controller release];

Then the user does the work and you get the delegate callback in time:

- (void)mailComposeController:(MFMailComposeViewController*)controller  
          didFinishWithResult:(MFMailComposeResult)result 
                        error:(NSError*)error;
{
  if (result == MFMailComposeResultSent) {
    NSLog(@"It's away!");
  }
  [self dismissModalViewControllerAnimated:YES];
}
like image 107
PeyloW Avatar answered Sep 19 '22 20:09

PeyloW