2

I am sending image with some text in Email Body using this link my code is given below

NSString *urlString = @"url";
NSString *searchingurl = [NSString stringWithFormat:@"%@%@", urlString,idnumber];
NSString *string = [NSString stringWithFormat:@"%@<br><br>Item No :%@<br>Type :%@<br>Size : %@",searchingurl,str123,mytype,itemsize];
NSMutableString *emailBody = [[[NSMutableString alloc] initWithString:@"<html><body>"] retain];
NSData *imageData = UIImageJPEGRepresentation(myImage, 1.0f);
NSString *encodedString = [imageData base64Encoding];
[emailBody appendString:[NSString stringWithFormat:@"<p><b><img src='data:image/png;base64,%@'></b></p>",encodedString]];
[emailBody appendString:string];
[emailBody appendString:@"</body></html>"];
NSLog(@"%@",emailBody);
 MFMailComposeViewController *emailDialog = [[MFMailComposeViewController alloc] init];
emailDialog.mailComposeDelegate = self;
[emailDialog setSubject:@""];
[emailDialog setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:emailDialog animated:YES];
[emailDialog release];
[emailBody release];

Screenshow for above code

enter image description here

After Sending Mail to Yahoo it show my image and text on both Mackbook and in iphone device , when i send mail to Gmail and checked it in iphone device it show image with text but When i checked gmail in Mackbook it not show my image

Some one Can guide me why my image not show in Gmail on PC.Any help will be appriated.Thanks

Community
  • 1
  • 1
jamil
  • 2,409
  • 3
  • 34
  • 64
  • possible duplicate of [How to add a image in email body using MFMailComposeViewController](http://stackoverflow.com/questions/12210571/how-to-add-a-image-in-email-body-using-mfmailcomposeviewcontroller) – danh Feb 13 '13 at 17:50
  • @danh but i have different case your link show text before image but i want image before text in Email. – jamil Feb 13 '13 at 17:54
  • can't you just swap the order of what you add and add the text with mime type application/text – danh Feb 13 '13 at 18:03
  • @danh please post answer beacuse still i have some doubt if i change the order then in which formate i add my image in Email body and where i need to add it you means [emailDialog setMessageBody:emailBody isHTML:YES]; – jamil Feb 13 '13 at 18:06
  • @danh i am following http://stackoverflow.com/questions/1527351/how-to-add-an-uiimage-in-mailcomposer-sheet-of-mfmailcomposeviewcontroller-in-ip link but it not show image after sending Email. – jamil Feb 13 '13 at 18:12

1 Answers1

-1
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"Your subject"];


    // Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@""];
    //NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
    //NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];

    [picker setToRecipients:toRecipients];
    //[picker setCcRecipients:ccRecipients];
    //[picker setBccRecipients:bccRecipients];


    NSLog(@"Video size >> %d",(videodta.length/1024)/1024);
  [picker addAttachmentData:imageData mimeType:@"image/png" fileName:@"testapp"];

    // Fill out the email body text
    NSString *emailBody = @"Type your message here";
    [picker setMessageBody:emailBody isHTML:NO];

    [self presentModalViewController:picker animated:YES];
    }
Rajneesh071
  • 29,619
  • 13
  • 57
  • 72