Corey Powell Corey Powell - 1 year ago 70
Objective-C Question

Plist email attachment disappearing

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

Answer Source
  • (IBAction)EmailCSVdata:(id)sender {


    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:@""]; [controller2 setToRecipients:toRecipents];


    [controller2 addAttachmentData:csvData mimeType:@"application/x-sqlite3" fileName:@"SVR.sql"];

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download