Search code examples
objective-cuiviewxcode4ios4mfmailcomposeviewcontroller

Has any image size limitation for image send to mail in ios application?


I am new in ios development .Now i am trying to develop an ipad application .In my application sent an image to mail,the image means a uiview and converted to uiimage with the following code and sent to mail

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{
UIGraphicsBeginImageContext(intermediateView.frame.size);
[intermediateView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();


CGRect rt=intermediateView.frame;
NSLog(@"size of intermediate view %@",NSStringFromCGRect(rt));


    if(buttonIndex==1)
    {




       if([MFMailComposeViewController canSendMail]) 
       {

        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;
        [picker setSubject:@"Image Of Road Accident"];

        //UIImage *roboPic =image;
        NSData *imageData = UIImageJPEGRepresentation(viewImage, 1);
        [picker addAttachmentData:imageData mimeType:@"image/jpg" fileName:@"RobotWithPencil.jpg"];

        NSString *emailBody = @"This  image from my phone!";
        [picker setMessageBody:emailBody isHTML:YES];

        [self presentModalViewController:picker animated:YES];

    }
       else
       {
           NSLog(@"An error occur for our display");
       }
    }

Basically this code work fine.My applications need is to drag and drop images from a menu. If large amount of image add to the UIView ,the image(UIView) can not save to mail (The application will break).

Has any image size limitation for image send to mail in ios application?

How can overcome this issue?

If anybody know ,please help me.


Solution

  • Your Server may have restricted Image Size Limit. You should increase image upload limit.