Search code examples
iphoneemailpdfmime

what is mime type its not working as i m using application/pdf to sending in iphone


MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self;

    [picker setMessageBody:@"Invoice Report Pdf File" isHTML:NO];



    NSMutableData *pdfData =[NSMutableData dataWithContentsOfFile:filePath];

    [picker addAttachmentData:pdfData mimeType:@"application/pdf" fileName:self.pdfName];

Solution

  • Change mime type according my code, it will help you.

    NSMutableData *pdfData = [NSMutableData data]; UIGraphicsBeginPDFContextToData(pdfData, bounds, nil);
    

    Then at some point in the future you'll need to pass that pdfData to the MFMailComposeViewController.

    MFMailComposeViewController *vc = [[[MFMailComposeViewController alloc] init] autorelease]; [vc setSubject:@"my pdf"]; [vc addAttachmentData:pdfData mimeType:@"image/pdf" fileName:@"SomeFile.pdf"];