gpt4 book ai didi

iphone - 未收到从 MFMailComposer 发送的附件

转载 作者:行者123 更新时间:2023-12-03 20:16:18 24 4
gpt4 key购买 nike

我正在尝试在 iPad 上发送一封带有 .csv 附件的电子邮件。我根据下面显示的许多示例使用 MFMailComposer。发送电子邮件时,我可以在 MFMailComposer 窗口中看到正确的文件附件,但是当我收到电子邮件时,没有附加任何内容。任何关于我可能做错了什么的指导将不胜感激。谢谢您的宝贵时间,

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 需要包含文件的完整系统路径,而不仅仅是它的名称!

NSString *dataFilePath = [[NSBundle mainBundle] pathForResource:dataFileName ofType:nil];

关于iphone - 未收到从 MFMailComposer 发送的附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5182058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com