我想将本地文件从资源文件夹发送到电子邮件,但它不起作用如何添加本地文件。下面是从 iphone 的文档文件夹发送电子邮件但我想从资源文件夹发送电子邮件的代码
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString*giveFileName=@"CPAC_Contract_Equine";
NSString *fileName;
//fileName = [[NSString alloc]initWithFormat:@"%@.pdf",giveFileName];
fileName = [[NSString alloc]initWithFormat:@"%@",giveFileName];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];
NSLog(pdfFileName);
NSMutableData *myPdfData = [NSMutableData dataWithContentsOfFile:pdfFileName];
[picker setSubject:@"CPAC Contract for Equine-Sam Veterinarian"];
[picker addAttachmentData:myPdfData mimeType:@"application/pdf" fileName:giveFileName];
[self.navigationController presentViewController:picker animated:YES completion:nil];