It seems to me that I was looking for a watch, trying to find a solution, and nothing worked. Anyway, here's how I managed to send the PDF from the URL as an attachment via email in the iOS app.
-(void)emailDocument:(id)sender { MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init]; NSString *emailSubject = [NSString localizedStringWithFormat:@"Hi, I'm the subject"]; [controller setSubject:emailSubject]; NSString *path = @"http://www.somesite.com/document.pdf"; NSURL *pdfURL = [NSURL URLWithString:path]; NSData *pdfData = [NSData dataWithContentsOfURL:pdfURL]; [controller addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"documentname.pdf"];
So my question is: are there any potential problems with this? And how can I address the error checking the returned data?
source share