You could do like the following.
Create a MFMailComposeViewController
and use - (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
method to add your attachment.
For example.
MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];
[mailVC setSubject:@"Shared documents"];
[mailVC setToRecipients:@[@"sample@example.com"]];
[mailVC setMessageBody:@"Here the docs I want to share" isHTML:NO];
[mailComposer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"file.pdf"];
[mailVC setMailComposeDelegate:self];
[self presentViewController:mailVC animated:YES completion:nil];
where pdfData
is of type NSData
. So, you need to transform your document into a NSData
.
From Apple doc.
addAttachmentData:mimeType:fileName:
This method attaches the specified data after the message body but
before the user’s signature. You may attach multiple files (using
different file names) but must do so prior to displaying the mail
composition interface. Do not call this method after presenting the
interface to the user.
About the second part of your question. Could you explain what type of document do you need to display?
In the meantime, take a look at Adding "Open In..." option to iOS app.