调用IOS邮件系统发送邮件
1.導入MessageUI.framework框架
2.在需要應用的控制器頭文件:#import <MessageUI/MessageUI.h>,并加入委托:<MFMailComposeViewControllerDelegate>
3.實現方法:
-(void)displayComposerSheet?
{
??? MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
??? picker.mailComposeDelegate = self;
????
??? [picker setSubject:@"Enter Your Subject!"];
????
??? // Set up recipients
??? NSArray *toRecipients = [NSArray arrayWithObject:@"donald.wong5@gmail.com"];?
??? ?
????
??? [picker setToRecipients:toRecipients];
? ??
??? // Attach an image to the email
??? NSString *path = [[NSBundle mainBundle] pathForResource:@"" ofType:@"png"];
??? NSData *myData = [NSData dataWithContentsOfFile:path];
??? [picker addAttachmentData:myData mimeType:@"image/png" fileName:@""];
????
??? // Fill out the email body text
??? ?????
??? [self presentModalViewController:picker animated:YES];
????
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error?
{????
??? ?
??? [self dismissModalViewControllerAnimated:YES];
}
轉載于:https://www.cnblogs.com/hellocby/archive/2012/09/19/2693680.html
總結
以上是生活随笔為你收集整理的调用IOS邮件系统发送邮件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软件工程期末复盘
- 下一篇: R语言批量下载PubMed摘要