2010-07-26 49 views
0

我的PDF文件作为附件出现在UIWebView和iphone上的邮件屏幕上。当我将它发送到我的电子邮件(使用两个不同的电子邮件运营商)时,它会被删除 - 没有文件附件。我可以发送PDF到这些电子邮件帐户在我的iPhone和转发他们好,所以我不认为它是我的电子邮件提供商,但iOS是剥离文件?我可以附加图片确定但不是PDF文件。不知道问题出在哪里,以及如何找到问题发生的地方。谢谢!PDF文件从iPhone剥离MFMailComposeViewController调用

我的代码:

-(void)doSendEmail :(NSString *)use_email :(NSString *)amsg { 
    if ([MFMailComposeViewController canSendMail]) { 
     MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init]; 
     controller.mailComposeDelegate = self; 
     [controller setToRecipients:[NSArray arrayWithObjects:use_email, nil]]; 

      NSString *filen=self.filepath1; 
      NSString *pdfPath = [[NSBundle mainBundle] pathForResource:filen ofType:@"pdf"]; 
      NSData *pdfData = [NSData dataWithContentsOfFile:pdfPath]; 
      [controller addAttachmentData:pdfData mimeType:@"application/pdf" fileName:self.filename1] 
     } 


    //Set messages 
    [controller setSubject:self.subject]; 
    [controller setMessageBody:amsg isHTML:NO]; 

    //Display email for user to send 
    [self presentModalViewController:controller animated:YES]; 
    [controller release]; 
} 

-(void)mailComposeController:(MFMailComposeViewController*)controller 
      didFinishWithResult:(MFMailComposeResult)result 
         error:(NSError*)error { 
    if ((result == MFMailComposeResultSent) && (stat==4)) { 
     billsent=1; 
    } 
    [self dismissModalViewControllerAnimated:YES]; 
} 

回答

0

这是一个老问题,但我在谷歌碰到它搜索,所以我想我会发布我的解决方案:

这可能是您pdfPath是错误的。如果PDF是作为附件正确加载的,您应该而不是请参阅附件的图标。相反,您会看到pdf本身的大图。

如果您在NSData *pdfData =之后立即设置一个断点并将鼠标悬停在pdfData上,它可能会告诉您零字节的数据为零。