0

I have a mailcomposer in which i have attached a file through coding(hard-coded)..

I need to have a button so that When i press the button.It should ask which file to attach...

My code is shown below in which i am attaching the file hordcoded...

UIImage *img=[UIImage imageNamed:@"Mehmood.jpg"];
NSData *imgData=UIImageJPEGRepresentation(img, 1);
[composer addAttachmentData:imgData mimeType:@"image/jpeg" fileName:@"Mehmood.jpg"]; 

Even I need to attach any file which i am selecting after button click(not the specific one like png/jpeg)...

Please help... Thanks in advance

Kamar Shad
  • 6,089
  • 1
  • 29
  • 56
vshall
  • 619
  • 7
  • 26

2 Answers2

0

maybe this will help you.

Where's the iPhone MIME type database?

Community
  • 1
  • 1
ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
  • Sorry,I didnot understand... I need to select a file from my ipad/iphone whether it be from phone or it's memory card of phone(if present).... How to add button for composing mail in the mfMailComposerViewController for selecting the attachment... – vshall Apr 04 '12 at 10:12
  • @vishaldharmawat its a link dude chek this link . it shows that code return myme type. maybe that would help u. – ChintaN -Maddy- Ramani Apr 04 '12 at 10:13
  • http://stackoverflow.com/questions/7824647/send-an-iphone-attachment-through-email-programmatically – Anand Apr 04 '12 at 10:14
  • http://stackoverflow.com/questions/8846338/pdf-as-an-email-attachment-in-ios-device – Anand Apr 04 '12 at 10:14
  • Sorry...but tell me can we add button for selecting attachment in mailcomposer..like we get button for attaching file in gmail...If yes,,then how?.. – vshall Apr 04 '12 at 10:22
  • @vishaldharmawat https://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html – ChintaN -Maddy- Ramani Apr 04 '12 at 10:33
  • @vishaldharmawat this link tell you that u cant customize mailcomposer . so i thnk you cant add button. – ChintaN -Maddy- Ramani Apr 04 '12 at 10:33
  • then Chinttu how can i add attachment depending upon my choice if not hardcoded... – vshall Apr 04 '12 at 10:38
  • @vishaldharmawat i gave you that link maybe it will return mime type. i didnt use but i just search for you. so u have to just pass file name there and it will return mime type. try it maybe it will help you. not sure. – ChintaN -Maddy- Ramani Apr 04 '12 at 10:40
0

You cannot really modify the standard mail composer window to add your own buttons. You should ask the user what they want to attach before presenting the mail composer.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151