iOS Xcode电子邮件附件无法以正确格式提供文本

时间:2014-05-21 20:43:41

标签: xcode email email-attachments

我有一个简单的柱状文本报告,我存储在文档目录中,即

------------按商店报告------------

商店:Vegas Outlet Manager:Joe Smith
   地址123 Story Lane    拉斯维加斯,内华达州12345    销售额3000.00

商店:纽约经理:Frank Jones    地址321 Broadway    Mew York,NY 12345    销售5555.00

商店:St Louis Outlet经理:Ozzie Davis
   地址88 Main Street    圣路易斯维加斯,MI 12345    销售额3333.00

当我将它附加到Xcode中的programaticaly电子邮件并发送时,所有间距和CR都会显示。当我打开电子邮件并查看我得到的附件时:

------------商店报道------------商店:Vegas OutletManager:JoeSmithAdddress 123故事LaneLas Vegas,NV 12345Sales 3000.00Store:New YorkManager:Frank JonesAddress 321 BroadwayMew York,NY 12345Sales 5555.00Store:St Louis Outlet Manager:OzzieDavisAddress 88 Main StreetSt Louis Vegas,MI 12345Sales 3333.00

当我使用gmail yahoo ...将完全相同的文件附加到电子邮件时

格式正确

我试过mimeType:@“text / plain”,mimeType:@“text / csv”,mimeType:@“html”

其他人遇到这个?

这是代码

NSString* filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* fileName = @"ReportSomething.txt";
NSString* fileAtPath = [filePath stringByAppendingPathComponent:fileName];
NSData *fileData = [NSData dataWithContentsOfFile:fileAtPath];

NSString *textFromFile = @"";

textFromFile = [NSString stringWithContentsOfFile:fileAtPath encoding:NSUTF8StringEncoding error:nil];
NSString *emailTitle = @"Report from home Office";
NSString *messageBody = @"See Attached Report";

// To address
// NSArray *toRecipents = [NSArray arrayWithObject:@"whoEver@gmail.com"];

[self getDefaultEmail];

//   NSArray *toRecipents = defEmail;
NSArray *toRecipents = [NSArray arrayWithObject:defEmail];



MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];

// here's where the problem is 
[mc addAttachmentData:fileData mimeType:@"text/csv" fileName:fileName];
 //   [mc addAttachmentData:fileData mimeType:@"text/x-pdf" fileName:fileName];


// Present mail view controller on screen

[self presentViewController:mc animated:YES completion:NULL];

我再次使用safari浏览器/ gmail附加文件,并以正确的格式接收

使用iOS NO格式附加/邮寄它

0 个答案:

没有答案