Copy this code in to your program and add Ui Message framework and add
|
1 |
#import <MessageUI/MessageUI.h> |
to .h file .
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
-(IBAction)Email_Button { NSLog(@"Email"); MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; // <- very important step if you want feedbacks on what the user did with your email sheet [picker setSubject:@"BHAGAVAD GITA "]; NSString *emailBody = textShow.text; [picker setMessageBody:emailBody isHTML:YES]; // depends. Mostly YES, unless you want to send it as plain text (boring) picker.navigationBar.barStyle = UIBarStyleBlack; // choose your style, unfortunately, Translucent colors behave quirky. //attaching csImage=[NSString stringWithFormat:@"gita%d",100*chapterInt+slokamInt] ; NSData *imageData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"gita%d",100*chapterInt+slokamInt] ofType:@"gif"]]; [picker addAttachmentData:imageData mimeType:@"image/gif" fileName:[NSString stringWithFormat:@"gita%d.gif",chapterInt+slokamInt] ]; [self presentModalViewController:picker animated:YES]; [picker release]; } - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { // Notifies users about errors associated with the interface switch (result) { case MFMailComposeResultCancelled: break; case MFMailComposeResultSaved: break; case MFMailComposeResultSent: break; case MFMailComposeResultFailed: break; default: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@" Sending Failed" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil]; [alert show]; [alert release]; } break; } [self dismissModalViewControllerAnimated:YES]; } |
Incoming search terms:
- attach image to email xcode
- sending image via mail xcode
- attach a photo to email xcode
- how to attach picture in email in xcode
- xcode email image and text
- xcode mail



