1. 导入框架:MessageUI.framework
2. 添加协议:<MFMailComposeViewControllerDelegate>
3. #import <MessageUI/MessageUI.h>
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; //设置委托 mc.mailComposeDelegate = self; //设置邮件主题 [mc setSubject:@"Hello World!"]; //设置收件人 [mc setToRecipients:[NSArray arrayWithObjects:@"zhuqi@163.com"]]; //设置cc [mc setCcRecipients:[NSArray arrayWithObjects:@"78788@qq.com"]]; //设置bcc [mc setBccRecipients:[NSArray arrayWithObjects:@"789@qq.com"]]; //设置邮件内容 //[mc setMessageBody:@"This is a test mail" isHTML:NO]; //设置邮件内容,支持HTML [mc setMessageBody:@"<HTML><B>Hello, Joe!</B><BR/>What do you know?</HTML>" isHTML:YES]; //为邮件添加附件 NSString *path = [[NSBundle mainBundle] pathForResource:@"orange" ofType:@"png"]; NSData *data = [NSData dataWithContentsOfFile:path]; [mc addAttachmentData:data mimeType:@"image/png" fileName:@"orange"]; [self presentModalViewController:mc animated:YES]; [mc release]; #pragma mark - #pragma mark Delegate Method -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { switch(result) { case MFMailComposeResultCancelled: NSLog(@"Mail send canceled..."); break; case MFMailComposeResultSaved: NSLog(@"Mail saved..."); break; case MFMailComposeResultSend: NSLog(@"Mail send..."); break; case MFMailComposeResultFailed: NSLog(@"Mail send errored:%@...",[error localizedDescription]); break; default: break; } [self dismissModalViewControllerAnimated:YES]; }