Thursday, 10 November 2011

Launch iPhone/iPad email composer in your application


MFMailComposeViewController  class is used to editing and email, its present in MessageUI.framework.

canSendMail method is used to find whether the user has set up the device for sending email .

Here launched email composer in my application, presenting as a modal popover.

if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
mail.navigationBar.tintColor = [UIColor redColor]; // your navigationbar color
mail.mailComposeDelegate = self;
[mail setSubject:@"Check out my iPhone/iPad app"];
[mail setMessageBody:@"<html><body>Check out <a href='http://karthik-prabhu.blogspot.in/'>iVerde</a></body></html>" isHTML:YES];
        //mail.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
       // [self setModalPresentationStyle:UIViewAnimationOptionTransitionFlipFromTop];
            [self presentViewController:mail animated:YES completion:NULL ]; //presentModalViewController deprecated from iOS5 and above 
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"App name Message" message:@"Please setup at least One email account." delegate:self cancelButtonTitle:nil      otherButtonTitles: @"OK", nil];
[alert show];
[alert release];
}





1 comment:

  1. Nice post. I was checking continuously your blog and I’m impressed! Extremely very useful information. I was looking for this particular info for a very long time. check here some relevant information like this Mobile App Development

    ReplyDelete