tags:

views:

31

answers:

2

hi i am new to iphone. what i need id i have to open [email protected] on button click. i need simple compose mail with to address [email protected] how can i done this pls post some code thank u.

+1  A: 

First you want to check if [MFMailComposeViewController canSendMail] is YES. If so, then you can send e-mail, otherwise, no accounts are setup.

Next you'll want to create an MFMailComposeViewController, and conform to the MFMailComposeViewControllerDelegate delegate. From there, on your MFMailComposeViewController, you will want to look at the -setSubject:, -setMessageBody:isHTML: and the -setToRecipients: methods, and finally on your "parent" view controller, -presentModalViewController:animated: to bring your compose view up for the user to send the mail, and release your MFMailComposeViewController.

jer
+1  A: 

Hi MaheshBabu,

Use this code into your button action,

      MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
      [[mail navigationBar] setTintColor:[UIColor blackColor]];// Change the navigation bar color
       mail.mailComposeDelegate = self;

       if ([MFMailComposeViewController canSendMail]) {

               [mail setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];

               [self presentModalViewController:mail animated:YES];
    }

    [mail release];

For more clarification, see my answer

Best Of Luck.

Pugal Devan