Goutham
Goutham

Reputation: 297

not able to send attachments to another email address

In my app, using MFMailComposer I'm not able to send attachments to another mail address. Those attachments are in a link.

I'm using this code:

 NSData *textData = [NSData dataWithContentsOfFile:self.fileString];
[mailView addAttachmentData:textData mimeType:@"text/plain" fileName:self.fileString];

 

Upvotes: 2

Views: 188

Answers (2)

NiravPatel
NiravPatel

Reputation: 3260

Try below code for sending attachment in email..

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Subject"];
NSData *textData = [NSData dataWithContentsOfFile:self.fileString];
[picker addAttachmentData:imageData mimeType:@"text/plain" fileName:@"rainy"];
[self presentViewController:picker animated:YES completion:nil];
[picker release];

what you do in addAttachmentData method is replace self.fileString in fileName with other name like I have written. let me know it is working or not.

Upvotes: 2

onevcat
onevcat

Reputation: 4631

I guess the fileName is the path of your text file. And then you pass this path ( self.fileString) to -addAttachmentData:mimeType:fileName:. It is not correct using of attach data to mail. You just need to set a plain string as the file name of the attach file, maybe @"attachText.txt" will be a good choice.

Upvotes: 0

Related Questions