I am a just getting started with Xcode and trying to finish my first app, the final part is to email the Plist, I have used this save path:
- (NSString *)dataFilePath6 {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:@"data6.plist"];
and this attach method:
NSString *path = [[NSBundle mainBundle] pathForResource:@"data6" ofType:@"plist"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mc addAttachmentData:myData mimeType:@"application/xml" fileName:@"data6.plist"];
When I run the app on my iPad, the file shows as an attachment and the email sends, but when I receive the email there is no attachment.
Basically I just needed to get the data the user had imputed into the UITextField
s.
- (IBAction)EmailCSVdata:(id)sender {
//sqlite3
NSArray *pathssqlite = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fileName = @"SVR.sql";
NSString *documentsDirectory2 = [pathssqlite objectAtIndex:0];
NSString *csvPathwithFileName = [documentsDirectory2 stringByAppendingPathComponent:fileName];
NSData *csvData = [NSData dataWithContentsOfFile:csvPathwithFileName];
MFMailComposeViewController *controller2 = [[MFMailComposeViewController alloc] init];
controller2.mailComposeDelegate = self;
[controller2 setSubject:@"Store Visit SQL DB..."];
[controller2 setMessageBody:@"Store Visit SQL DB For V3.5 is here.." isHTML:YES];
NSArray *toRecipents = [NSArray arrayWithObject:@"XXX@.com"];
[controller2 setToRecipients:toRecipents];
//sqlite3
[controller2 addAttachmentData:csvData mimeType:@"application/x-sqlite3" fileName:@"SVR.sql"];
[self presentViewController:controller2 animated:YES completion:NULL];
}