0

How to add web view data and image view data to Mfmailcomposer view controller in ios. for sending mail to others.

marko
  • 9,029
  • 4
  • 30
  • 46
12345
  • 157
  • 3
  • 10

4 Answers4

2

you can Firest Create a imageFull path Array what you want attech with Email and do like bellow:-

- (IBAction)sendemail
{

    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail])
        {


            MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
            picker.mailComposeDelegate = self;
            [picker setSubject:@"Hello"];
            //NSString *result = txtFiled.text;
            for(NSString *dicsss in buttonss) // Hear buttonss its a ImagePathfull array
            {
                UIImage *imgvith = [UIImage imageWithContentsOfFile:[buttonss stringByAppendingPathComponent:dicsss]];
                NSData *data = UIImagePNGRepresentation(imgvith);
                [picker addAttachmentData:data mimeType:@"image/png" fileName:@"yourImagename"];

            }


            NSString *emailBody = @"Hi";
            [picker setMessageBody:emailBody isHTML:YES];
            [self presentModalViewController:picker animated:YES];
            [picker release];
        }


}

Working Code screenShot look like:-

enter image description here

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
0

You can use

for (UIImage *yourImage in YourImageArray )
{
            NSData *imgData = UIImageJPEGRepresentation(yourImage, 0.5);
            [mfMailComposer addAttachmentData:imgData mimeType:@"image/jpeg" fileName:[NSString  
            stringWithFormat:@"a.jpg"]];
}
spider1983
  • 1,098
  • 1
  • 7
  • 14
0

Best solution is

[mailCompose setMessageBody: msg isHTML: YES];

where msg have value:

<body>
<img src='http://your_site/image1.jpg'>
<img src='http://your_site/image2.jpg'>
<br/>

<font face='Arial' size='2'>
  Message Text<br/>

  <br/>
</font>

CReaTuS
  • 2,593
  • 1
  • 19
  • 31
0

You can add more than one Image in your mail composer instanse. But make sure file name is is different. Check it here: http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMailComposeViewController_class/Reference/Reference.html#//apple_ref/doc/uid/TP40008200-CH1-SW2.

rptwsthi
  • 10,094
  • 10
  • 68
  • 109