MFMailComposer -- 附加带有 HTML 的图像
我正在尝试发送一封带有图像附件并打开 HTML 的电子邮件。问题是,当 HTML 启用时,图像会内嵌显示,而不是作为附件显示(我使用 gmail)。
如果我设置 isHTML:NO 那么图像会正确显示为可下载附件。如何将图像作为带有 html 消息的附件发送?
NSData *imageAttachment = UIImageJPEGRepresentation(myUIImage,1);
MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
[mailView setSubject:@"My Email Subject!"];
[mailView addAttachmentData:imageAttachment mimeType:@"image/jpeg" fileName:@"imageAttachment.jpg"];
[mailView setMessageBody:messageBody isHTML:YES];
谢谢~!!
I am trying to send an email with an image attachment and HTML turned on. The problem is that when HTML is on, the image appears inline instead of as an attachment (I use gmail).
If I set isHTML:NO then the image properly shows up as a downloadable attachment. How can I send the image as an attachment with an html message?
NSData *imageAttachment = UIImageJPEGRepresentation(myUIImage,1);
MFMailComposeViewController *mailView = [[MFMailComposeViewController alloc] init];
[mailView setSubject:@"My Email Subject!"];
[mailView addAttachmentData:imageAttachment mimeType:@"image/jpeg" fileName:@"imageAttachment.jpg"];
[mailView setMessageBody:messageBody isHTML:YES];
Thanks~!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您附加图像的方法是正确的,您得到的结果也符合标准。
无论哪种方式,最终用户(无论是否使用 Gmail)都应该获得附件。
例如,Windows Live Mail 应该将其视为附件,而在 Mac OS 中使用“邮件”时,您会看到内联图像。
Your method for attaching the image is correct, and the results you are getting are also up to par.
Either way, the end user (whether they use Gmail or not) should get the attachment.
For instance, Windows Live Mail should see it as an attachment, where as using Mail in Mac OS, you would see the image inline.
您必须将图像添加为附件。您在 HTML 中看到的呈现的电子邮件无法通过缺少图像 URL 正确呈现。
这是一个例子:需要注意的是,如果您想包含 PDF 之类的内容,则必须包含图像,否则 mfmailcomposer 将失败......这是苹果错误。
我找到了解决方案...我在苹果雷达上提交了一个关于它的错误。 MFMailcomposer 有一个错误,您必须发送图像以及额外的附件才能使 pdf 之类的奇怪项目正常工作...尝试此操作并将 pdf 替换为您的卡片:
You have to add the images as an attachment. The rendered email that you see with HTML doesn't get rendered properly with the missing image URL.
here is an example: the caveat is that if you want to include things like a PDF you must include an image otherwise mfmailcomposer will fail... this in an apple bug.
I found the solution... Isubmitted a bug on Apple radar about it. MFMailcomposer has a bug in which you have to send an image along with your extra attachments in order to get the weird items like a pdf to work... try this and replace the pdf with your card: