0
Все, В моем требовании необходимо отправить почту с прикрепленным текстовым файлом, который находится в каталоге документа. Здесь я могу получить путь к файлу, который находится в каталоге документа. Как присоединить файл из моего ipad для отправки.Получить текстовый файл из каталога документов ipad
вот код, который я пытался
MFMailComposeViewController *picker=[[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate=self;
if ([MFMailComposeViewController canSendMail]){
// Create and show composer
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSLog(@"directry path %@",paths);
NSString *fullPath = [[paths lastObject] stringByAppendingPathComponent:@"Logs/log-858743.txt"];
NSLog(@"directry full path %@",fullPath);
NSData *data = [NSData dataWithContentsOfFile: fullPath];
NSLog(@"Data value %@",data);
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:fullPath];
if (fileExists) {
NSLog(@"file is there");
}else{
NSLog(@"file is not there");
}
[picker setSubject:@"Backup"];
[picker addAttachmentData:data mimeType:@"text/rtf" fileName:@"log.txt"];
[picker setMessageBody:@"testing." isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release]; }
else{
// Show some error message here
}
Как использовать это новичок для iphone – ganesh
попробуйте изменить [picker addAttachmentData: data mimeType: @ "text/rtf" fileName: @ "l og.txt "]; С помощью [picker addAttachmentData: data mimeType: @ "text/plain" fileName: @ "log.txt"]; – Tommaso