Using ZipArchive Zip file in iphone mail application?

can I send a zip archive inside an email attachment using the mail api?

+3
source share
2 answers

Try it .. It worked for me

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];
+8
source

Yes it is possible.

    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];

You can choose the path to the file, the file name of your choice. Please check the mime type if it does not work.

:)

+1
source

Source: https://habr.com/ru/post/1764210/


All Articles