[英]Why MFMailComposer with <img> is not showing the image in mail?
我正在使用MFMailComposer在郵件中發送一些圖像。 我將圖像轉換為Base64並使用<img>
標簽將圖像添加到 HTML 主體(我沒有將其添加為附件)。
[htmlString appendFormat:
@"<img src='data:image/png;base64,%@' width=300 height=200 />", imageAsBase64];
圖像在MFMailComposer中正確顯示,但從 MFMailComposer 發送的實際郵件中沒有顯示圖像。
我應該怎么做才能讓它工作?
幾周前我遇到了同樣的問題,我知道 Gmail 不支持嵌入式圖像。 您可以在其他郵件提供商(例如您的域 email)中看到 email 中的圖像,但在 Gmail 中看不到。
嘗試發送另一個 email 可以看到圖像。 您需要將圖像添加為附件,然后您才能看到圖像,它將顯示 email 主體的底部。
希望這有幫助。
您必須將圖像添加為附件。 您在 HTML 中看到的渲染 email 沒有正確渲染缺少的圖像 URL。
這是一個示例:需要注意的是,如果您想包含諸如 PDF 之類的內容,則必須包含圖像,否則 mfmailcomposer 將失敗……這在蘋果錯誤中。
我找到了解決方案...我在 Apple 雷達上提交了一個關於它的錯誤。 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];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.