views:

16

answers:

2

i hav a file with some data and i want to attach this file to mail, and i am using the default mail composer ...

any idea how to attach the file to mail before sending to receipents....

Thanks in advance....

A: 

Example with an attached image:

NSData *myData = UIImagePNGRepresentation(myImage);
[mailComposer addAttachmentData:myData mimeType:@"image/png" fileName:@"MyImage"];
jv42
i am using MFMailComposeViewController and if i hav data file (.doc or pdf ) then how should i attach this type files to mail
lak in iphone
Obtain a `NSData *` representation of your file, then attach with the same method, using the appropriate mimeType (Google MIME type if required).
jv42
A: 

NSString *path = [[NSBundle mainBundle] pathForResource:@"bg" ofType:@"jpg"];

NSData *myData = [NSData dataWithContentsOfFile:path];

[controller addAttachmentData:myData mimeType:@"image/jpg" fileName:@"Attachment-1"];
[self presentModalViewController:controller animated:YES];
lak in iphone