是否可以使用mail api?
在电子邮件附件中发送zip存档文件答案 0 :(得分:8)
试试这个..这个对我有用
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *WritableDBPath= [documentsDirectory stringByAppendingPathComponent:kFilename];
NSData *data = [NSData dataWithContentsOfFile:WritableDBPath];
[picker addAttachmentData:data mimeType:@"application/zip" fileName:@"/abc.zip"];
[picker setSubject:@"Database"];
[picker setMessageBody:@"Database testing" isHTML:NO];
[self presentModalViewController:picker animated:YES];
答案 1 :(得分:1)
是的,这是可能的。
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *WritableDBPath= [documentsDirectory stringByAppendingPathComponent:kFilename];
NSData *data = [NSData dataWithContentsOfMappedFile:WritableDBPath];
[picker addAttachmentData:data mimeType:@"text/richtext" fileName:@"/abc.zip"];
[picker setSubject:@"Database"];
[picker setMessageBody:@"Database testing" isHTML:YES];
[self presentModalViewController:picker animated:YES];
您可以根据自己的选择选择文件路径,文件名。如果它不起作用,请验证mime类型。
:)