problem at opening compose mail
hi i am new to iphone. what i need id i have to open support@ensisinfo.co开发者_JAVA百科m on button click. i need simple compose mail with to address support@ensisinfo.com how can i done this pls post some code thank u.
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:@"support@ensisinfo.com",nil]];
[self presentModalViewController:mail animated:YES];
}
[mail release];
For more clarification, see my answer
Best Of Luck.
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
.
精彩评论