簡體   English   中英

未收到MFMailComposer發送的附件

[英]Not receiving attachments sent from MFMailComposer

我想在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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM