Not receiving attachments sent from MFMailComposer
Asked Answered
G

1

3

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];

} 
Gombosi answered 3/3, 2011 at 14:31 Comment(1)
Do you see the attachment in your sent mailbox folder? Also not really relevant to the problem but I think your missing a textData release at the end.Pecan
P
0

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];
Previous answered 20/2, 2013 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.