不接收从MFMailComposer发送的附件 [英] Not receiving attachments sent from MFMailComposer
问题描述
我正试图在iPad上发送带有.csv附件的电子邮件。我正在使用MFMailComposer给出的许多示例,如下所示。发送电子邮件时,我可以在MFMailComposer窗口中看到正确的文件附件,但是当我收到电子邮件时,没有附加任何内容。任何关于我可能做错的指导都不胜感激。谢谢你的时间,
I am trying to send out an email with a .csv attachment on the iPad. I am using the MFMailComposer per many examples given which is displayed below. When sending out the email, I can see the correct file attachment in the MFMailComposer window, but when I receive the email, nothing is attached. Any guidance as to what I may be doing wrong would be appreciated. Thank you for your time,
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:[NSString stringWithFormat:@"Results for Participant %d.", [delegate participantNumber]]];
[mailViewController setMessageBody:[NSString stringWithFormat:@"The results for Participant %d in Study: %@ are as follows:", [delegate participantNumber], [[delegate getAccountData:([delegate accountItems] * [delegate accountNumberInUse])] description]] isHTML:NO];
NSData *textData = [[NSData alloc] initWithContentsOfFile:dataFileName];
[mailViewController addAttachmentData:textData mimeType:@"text/csv" fileName:[NSString stringWithFormat:@"Participant_Info_#%d.csv", [delegate participantNumber]]];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
}
推荐答案
textData变量的内容,也只是从你的代码中猜出,dataFileName需要包含一个完整的文件系统路径,而不仅仅是它的名字!
Check the content of the textData variable, also (just guessing from your code) the dataFileName needs to contain a full system path to the file, not just it's name!
NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:dataFileName ofType:nil];
这篇关于不接收从MFMailComposer发送的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!