我正在使用MFMailComposeViewController
从应用内发送附件(pdf)。但是,当我在设备上测试时,我没有收到附件。知道可能是什么问题吗?
- (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];
}
答案 0 :(得分:1)
尝试理解这段代码,它有助于你。
- (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];
}
由于
答案 1 :(得分:0)
我遇到了有时会发送邮件的问题,但并非总是如此。事实证明这实际上是我的iPhone上的邮件应用程序中的电子邮件帐户的问题。为了解决这个问题,我做了以下几点:
在这3个步骤之后,邮件神奇地开始从我的应用程序再次发送。