没有收到从iOS app / MFMailComposeViewController发送的附件

我正在使用MFMailComposeViewController从应用程序内发送附件(pdf)。 但是,当我在设备上testing时,我没有收到附件。 任何想法可能是什么问题?

 - (void) emailDocument { MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; NSData *data = [[NSData alloc] initWithContentsOfURL:pdfURL]; mailController.mailComposeDelegate = self; [mailController setSubject:[self title]]; [mailController setMessageBody:@"Please find the attached documents." isHTML:YES]; [mailController addAttachmentData:data mimeType:@"application/pdf" fileName:@"document"]; [self presentModalViewController:mailController animated:YES]; } 

试着理解这个代码,它可以帮助你。

 - (void)viewDidLoad { if ([MFMailComposeViewController canSendMail]) myButton.enabled = YES; } - (IBAction)buttonPressed { MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; mailController.mailComposeDelegate = self; [mailController setSubject:@"Hello iPhone"]; [mailController setMessageBody:@"This is the MailSend Application...." isHTML:NO]; [self presentModalViewController:mailController animated:YES]; [mailController release]; } - (void)mailComposeController:(MFMailComposeViewController*)mailController didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { [self becomeFirstResponder]; [self dismissModalViewControllerAnimated:YES]; } 

谢谢

我有一个问题,有时会发送邮件,但并不总是。 事实certificate,这实际上是我的iPhone上的邮件应用程序中的电子邮件帐户的问题。 要解决,我做了以下几点:

  1. 从iPhone中删除您的邮件帐户。
  2. 重新添加邮件帐户
  3. 重新启动手机 – 我认为这是至关重要的,因为它导致了我的邮件帐户和设备之间的一些同步。

经过这3个步骤,邮件奇迹般地从我的应用程序再次始终发送。