使用MFMailComposer通过电子邮件发送CSV文件 [英] Email CSV file with MFMailComposer
问题描述
我想使用扩展名为.csv的NSString(已制成)创建文件,然后使用UIMessage框架通过电子邮件发送该文件.有人可以向我展示代码来创建文件(具有.csv扩展名和NSString的内容),然后将其附加到MFMailComposeViewController的代码.
I would like to create a file using a NSString (already made) with a .csv extension then email it using the UIMessage framework. So can someone show me the code to create a file (with a .csv extensions and with the contents of a NSString) then how to attach it to a MFMailComposeViewController.
推荐答案
这是将CSV文件附加到MFMailComposeViewController的方法:
This is how you attach a CSV file to a MFMailComposeViewController:
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"CSV File"];
[mailer addAttachmentData:[NSData dataWithContentsOfFile:@"PathToFile.csv"]
mimeType:@"text/csv"
fileName:@"FileName.csv"];
[self presentModalViewController:mailer animated:YES];
// Note: PathToFile.csv is the actual path of the file on your iOS device's
// file system. FileName.csv is what it should be displayed as in the email.
关于如何生成CSV文件本身,请在 https:上的 CHCSVWriter 类: //github.com/davedelong/CHCSVParser 将为您提供帮助.
As far as how to generate the CSV file itself, the CHCSVWriter class at https://github.com/davedelong/CHCSVParser will help you.
这篇关于使用MFMailComposer通过电子邮件发送CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!