Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3988066
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:12:30+00:00 2026-05-20T06:12:30+00:00

I feel like I looked for hours trying to find a solution and nothing

  • 0

I feel like I looked for hours trying to find a solution and nothing worked. Anyway, here’s how I’ve managed to send a PDF from a URL as an attachment through an in-app email on iOS.

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

    //[controller setToRecipients:[NSArray arrayWithObject:[NSString stringWithString:@"YourEmail@me.com"]]];
    //[controller setMessageBody:@"Custom messgae Here..." isHTML:NO];

    [self presentModalViewController:controller animated:YES];
    controller.mailComposeDelegate = self;
    [controller release];
}

So my question is, are there any potential problems with this? And how would I go about error checking the data coming back?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:12:30+00:00Added an answer on May 20, 2026 at 6:12 am

    First off, you’ve put no error checking in there to handle any issues if the PDF data couldn’t be loaded. (A better solution would be to use the NSData dataWithContentsOfURL:options:error: method and actively check to see if any errors occurred.)

    Additionally, if the PDF data is liable to be quite large, I’d be tempted to use an NSURLConnection to asynchronously load the PDF data in the background, prior to attempting to create the email if this is feasible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like this must have been asked before, but I've looked at Knockout
I feel like GUID/UUID questions have been done to death here, but I can't
I feel like a bit of a dummy here. I downloaded CCValidator for CruiseControl.NET
I feel like I am missing something - from what it seems, JSP comes
I feel like there's a simple solution to this, but I'm not really sure
I feel like I should know this but I've been stumped for hours now
I feel like I'm being stupid, but I can't find anywhere on the phpMyAdmin
I feel like a real noob posting this, but I can't seem to find
I have looked at few examples here Calling a Method from an Expression and
I feel like this question has been asked many times, but the solution is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.