gpt4 book ai didi

ios - 在 ios6 的 ipad 应用程序中将图像附加到电子邮件

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:44:00 27 4
gpt4 key购买 nike

我正在尝试将图像附加到电子邮件并将电子邮件发送到我的电子邮件地址。问题是,当我发送一封附有 4 或 5 张图片的电子邮件时,该应用程序会一直处理,最终会挂起并崩溃,并且不会发送电子邮件。它适用于一张图片。我认为这是因为图像组合在一起的大小。顺便说一句,我使用的是 iOS 6.. 如何限制发送的文件或图像的大小?或者可能涉及其他问题?同一个应用程序在 ios5 中工作....

邮件发送部分连同图片是:

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];
}

最佳答案

你的代码有问题我想不通但是你可以使用this project这是

将处理多个附加文件并处理所有情况。

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved: you saved the email message in the drafts folder.");
break;
case MFMailComposeResultSent:
NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
break;
default:
NSLog(@"Mail not sent.");
break;
}
// Remove the mail view
[self dismissModalViewControllerAnimated:YES];
}

关于ios - 在 ios6 的 ipad 应用程序中将图像附加到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13304371/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com