大佬教程收集整理的这篇文章主要介绍了ios – 如何在Xcode中的应用程序内发送电子邮件?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
-(IBACtion)sendEmail{ MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; [composer setMailComposeDelegate:self]; if ([MFMailComposeViewController canSendMail]) { [composer setToRecipients:[NSArray arrayWithObjects:@"FrankMurphy.CEO@RomansXIII.com",nil]]; [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; [self presentViewController:composer animated:YES]; } } -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { if(error) { UIAlertView *alert = [[UIAlertView alloc] initWithtitle:@"error" message:[NSString StringWithFormat:@"error %@",[error description]] delegate:nil cancelButtontitle:@"dismiss" otherButtontitles:nil,nil]; [alert show]; [self dismissviewControllerAnimated:YES]; } else { [self dismissviewControllerAnimated:YES]; } }@H_772_2@
#import <UIKit/UIKit.h> #import <messageUI/messageUI.h> @interface SimpleEmailViewController : UIViewController <MFMailComposeViewControllerDelegate> // Add the delegate - (IBACtion)showEmail:(id)sender; @end
在.m实现文件中…..
- (IBACtion)showEmail:(id)sender { // Email Subject NSString *emailtitle = @"Test Email"; // Email Content NSString *messageBody = @"iOS progrAMMing is so fun!"; // To address NSArray *toRecipents = [NSArray arrayWithObject:@"info@finetechnosoft.in"]; MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init]; mc.mailComposeDelegate = self; [mc setSubject:emailtitle]; [mc setmessageBody:messageBody isHTML:NO]; [mc setToRecipients:toRecipents]; // Present mail view controller on screen [self presentViewController:mc animated:YES completion:NULL]; } - (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { switch (result) { case MFMailComposeResultCancelled: NSLog(@"Mail cancelled"); break; case MFMailComposeResultSaved: NSLog(@"Mail saved"); break; case MFMailComposeResultSent: NSLog(@"Mail sent"); break; case MFMailComposeResultFailed: NSLog(@"Mail sent failure: %@",[error localizedDescription]); break; default: break; } // Close the Mail Interface [self dismissviewControllerAnimated:YES completion:NULL]; }@H_772_2@ @H_772_2@
以上是大佬教程为你收集整理的ios – 如何在Xcode中的应用程序内发送电子邮件?全部内容,希望文章能够帮你解决ios – 如何在Xcode中的应用程序内发送电子邮件?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。