我正在使用MFMailComposer在邮件中发送一些图像。我正在将图像转换为Base64,并使用<img>标记将图像添加到HTML (我没有将其作为附件添加)。
[htmlString appendFormat:
@"<img src='data:image/png;base64,%@' width=300 height=200 />", imageAsBase64];图像在MFMailComposer中正确显示,但在从MFMailComposer发送的实际邮件中没有显示图像。
我该怎么做才能让它发挥作用?
发布于 2011-07-07 07:37:42
几周前,我也遇到了同样的问题,我开始意识到Gmail不支持嵌入式图像。您可以在其他邮件提供商中看到图片,比如您的域邮件,而不是Gmail。
尝试发送另一封电子邮件,你可以看到图像。您需要添加图片作为附件,然后您可以看到图像,它将显示您的电子邮件正文底部。
希望能帮上忙。
发布于 2011-12-29 04:07:40
您必须将图像添加为附件。您在HTML中看到的已呈现的电子邮件没有通过缺少的图像URL正确地呈现。
这里有一个例子:警告是,如果您想包含像PDF这样的东西,您必须包括一个图像,否则mfmailcomposer将失败…这是苹果虫里的。
我找到了解决办法..。我在苹果雷达上提交了一个关于这件事的错误。MFMailcomposer有一个错误,你必须发送一个图像和你的额外附件,以获得奇怪的项目,如一个pdf的工作.试一试,用您的卡片替换pdf:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
NSString *emailSubject = [NSString localizedStringWithFormat:@"MedicalProfile"];
[controller setSubject:emailSubject];
NSString *fileName = [NSString stringWithFormat:@"%@.pdf", profileName];
NSString *saveDirectory = NSTemporaryDirectory();
NSString *saveFileName = fileName;
NSString *documentPath = [saveDirectory stringByAppendingPathComponent:saveFileName];
*** YOU MUST INCLUDE AN IMAGE OR THE PDF ATTATCHMENT WILL FAIL!!!***
// Attach a PDF file to the email
NSData *pdfData = [NSData dataWithContentsOfFile:documentPath];
[controller addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName];
// Attach an image to the email
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"miniDoc" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
[controller addAttachmentData:imageData mimeType:@"image/png" fileName:@"doctor"];
[controller setMessageBody:[NSString stringWithFormat:@"%@'s Medical Profile attatched!", profileName] isHTML:NO];
[self presentModalViewController:controller animated:YES];
controller.mailComposeDelegate = self;
[controller release];https://stackoverflow.com/questions/6607165
复制相似问题