我要瘋了這個代碼,它應該是工作,但是當我收到的郵件有沒有附加的文件,這裏是我的代碼:附加sqlite的Xcode的郵件
-(IBAction)mandar:(id)sender
{
MFMailComposeViewController *composer=[[MFMailComposeViewController alloc]init];
[composer setMailComposeDelegate:self];
if ([MFMailComposeViewController canSendMail])
{
[composer setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
[composer setSubject:@"Base de datos"];
[composer setMessageBody:@"Mensage" isHTML:NO];
[composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [searchPaths objectAtIndex:0];
NSString *path = [[NSString alloc] initWithFormat:@"%@/capturas.sqlite",documentPath];
NSString *Newpath = [[NSString alloc] initWithFormat:@"%@/newData.sqlite",documentPath];
[[NSFileManager defaultManager] copyItemAtPath:path toPath:Newpath error:nil];
NSData *data = [NSData dataWithContentsOfFile:Newpath];
[composer addAttachmentData:data mimeType:@"application/x-sqlite3" fileName:@"capturas.sqlite"];
[self presentModalViewController:composer animated:YES];
}
else {
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Error" message:@"No se a podido mandar el mensage" delegate:self cancelButtonTitle:@"dismis" otherButtonTitles:nil, nil];
[alert show];
}
}
的路徑是確定和數據庫中有數據,當我撰寫郵件時,我也會看到該文件,但沒有任何郵件到達我的郵件。我想這個問題是在這裏
[composer addAttachmentData:data mimeType:@"application/x-sqlite3" fileName:@"capturas.sqlite"];
,但不知道爲什麼它不工作,THX的幫助
可能重複(http://stackoverflow.com/questions/11499971/error-sending-database-from-xcode替換) – 2012-07-18 07:55:12
你可以附加sqlite文件,但你永遠無法打開它,例如,通過LiYa應用程序在MAC – ikzjfr0 2014-10-27 02:27:42