在ios6中的ipad中的应用程序中将图像附加到电子邮件 [英] Attaching a image to an email in an app in ipad in ios6

查看:177
本文介绍了在ios6中的ipad中的应用程序中将图像附加到电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图像附加到电子邮件中,并将电子邮件发送到我的电子邮件地址。问题是,当我发送附有4或5张图像的电子邮件时,该应用程序将永远处理,最终被挂起并崩溃,不会发送电子邮件。一个图像正常工作。我在想,这是因为图像的大小结合在一起。 Btw,我正在使用iOS 6 ..如何限制发送的文件或图像的大小?或者可能还有其他问题?相同的应用程序正在ios5 ....

I am trying to attach images to the email and send the email to my email add. The problem is that when i send out an email with 4 or 5 images attached, the app keeps processing for ever and eventually gets hanged and crashes and doesn't send the email. It is working fine with one image. I am thinking it is because of the size of the images combined together. Btw, I am using iOS 6.. How do i restrict the size of the files or images sent? Or there might be other issues involved? The same app is working in ios5....

电子邮件发送部分与图像一起是:

The email sending portion together with image is:

for (int nCtr = 0; nCtr < [Pix count]; nCtr++) {
            UIImageView *imageV = [Pix objectAtIndex:nCtr];
            if (imageV.image) {
                NSData *imageData = UIImagePNGRepresentation(imageV.image);
                NSString *strFileName = [NSString stringWithFormat:@"MyPicture-%d.jpeg",nCtr];

                NSString *strFormat = [NSString stringWithFormat:@"image/jpeg;\r\n\tx-unix-mode=0644;\r\n\tname=\"%@\"",strFileName];
                NSString *strFormat2 = [NSString stringWithFormat:@"attachment;\r\n\tfilename=\"%@\"",strFileName];
                NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:strFormat,kSKPSMTPPartContentTypeKey,
                                         strFormat2,kSKPSMTPPartContentDispositionKey,[imageData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];

                [images addObject:vcfPart];
            }


推荐答案

只需将其从PNG格式更改到JPEG格式。

Just change it from PNG format to JPEG format.

for (int nCtr = 0; nCtr < [arrPix count]; nCtr++) {
            UIImageView *imageV = [arrPix objectAtIndex:nCtr];
            if (imageV.image) {
                NSData *imageData = UIImageJPEGRepresentation(imageV.image, 0.9);
                NSString *strFileName = [NSString stringWithFormat:@"MyPicture-%d.jpeg",nCtr];

                NSString *strFormat = [NSString stringWithFormat:@"image/jpeg;\r\n\tx-unix-mode=0644;\r\n\tname=\"%@\"",strFileName];
                NSString *strFormat2 = [NSString stringWithFormat:@"attachment;\r\n\tfilename=\"%@\"",strFileName];
                NSDictionary *vcfPart = [NSDictionary dictionaryWithObjectsAndKeys:strFormat,kSKPSMTPPartContentTypeKey,
                                         strFormat2,kSKPSMTPPartContentDispositionKey,[imageData encodeBase64ForData],kSKPSMTPPartMessageKey,@"base64",kSKPSMTPPartContentTransferEncodingKey,nil];

                [parts addObject:vcfPart];
            }
        }

看起来ios6限制了图像的大小。 ..最好压缩图像...

It seems that ios6 limits the size of the images...Hence it is better to compress the image...

这篇关于在ios6中的ipad中的应用程序中将图像附加到电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆