Base64 图像到 Gmail [英] Base64 images to gmail

查看:35
本文介绍了Base64 图像到 Gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为从 iPad 发送的电子邮件生成一些内嵌图像.在所有桌面电子邮件客户端中看起来都很棒,但 gmail 似乎不喜欢 base64 图像,它显示为文本.

I'm generating some inline images for an email sent from the iPad. Looks great in all desktop email clients, but gmail doesn't seem to like the base64 image and it shows up as text.

有没有人在 base64 和 gmail 中嵌入图像有任何运气?或者知道从 iPad 发送带有图像的 HTML 电子邮件的更好解决方案吗?

Anyone have any luck embedding images with base64 and gmail? Or know of a better solution for sending HTML emails with images from the iPad?

推荐答案

来自 Moin Zaman 的链接显示了过时的测试结果(从 2008 年开始).根据我今天的全面测试,Gmail 确实支持显示两种方法的嵌入图像.

The links from Moin Zaman show test results that are outdated (from 2008). As of my thorough testing today Gmail does support displaying embedded images for both methods.

<img src="...">

<html><body><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9QAAADmCAIAAAC77FroAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAO..."></body></html>

使用 base64 编码的图像作为附件

Use base64 encoded image as attachment

Message-ID: <BE0243A40B89D84DB342702BC5FD6D313EA3BE1B@BYMAIL.example.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: yes
X-MS-TNEF-Correlator:
x-originating-ip: [xxx.xxx.xxx.xxx]

Content-Type: multipart/related;
    boundary="_038_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_";
    type="multipart/alternative"
MIME-Version: 1.0
Return-Path: email@example.com
X-OriginatorOrg: example.com

--_038_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_
Content-Type: multipart/alternative;
    boundary="_000_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_"

...skipping Content-Type: text/plain which would be here for this example...

--_000_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html><body><img border=3D"0" width=3D"980" height=3D"230" id=3D"Picture_x0020_1" src==3D"cid:image001.png@01CDA268.204677C0"></body></html>

--_000_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_--

--_038_BE0243A40B89D84DB342702BC5FD6D313EA3BE1BBYMAIL_
Content-Type: image/png; name="image001.png"
Content-Description: image001.png
Content-Disposition: inline; filename="image001.png"; size=32756;
    creation-date="Mon, 08 Oct 2012 15:27:07 GMT";
    modification-date="Mon, 08 Oct 2012 15:27:07 GMT";
Content-ID: <image001.png@01CDA268.204677C0>
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAA9QAAADmCAIAAAC77FroAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAO
xAAADsQBlSsOGwAAf5lJREFUeF7tvQlgVdW18L+ZR20mpsSLCYlBQKwgwRCMr9TAqzg0CAl98Y9a
ikBfHxL1A/r0tUr77Feg1mDav4LUijxTk8hLRIstQ2mJhEiAWAEpNCGRa8KUSQXCzLf2cOZz7j33
5s5Zx6j3nruHtX97n33WWWfttbtdv36d4IEEkAASQAJIAAkgASSABJCA/wl0938VWAMSQAJIAAkg
ASSABJAAEkAClAAq3zgOkAASQAJIAAkgASSABJBAgAig8h0g0FgNEkACSAAJIAEkgASQABJA5RvH
...

要进行自己的测试,您可以使用以下技术之一发送带有内嵌嵌入图像的电子邮件

To do your own testing, you can send email with inline embedded image using one of the following techniques

使用上述方法之一向您的 Gmail 帐户发送电子邮件,然后在 Gmail 网络客户端(任何可用的浏览器)中打开电子邮件并使用回复按钮旁边的向下箭头选择显示原始选项.这将向您展示它是如何被接收的.

Send an email using one of the above to your Gmail account, then open the Email in Gmail Web Client (any browser that works) and use the Down-Arrow next to the Reply button to choose the Show Original option. This will show you how it is received.

我认为最好的做法是使用嵌入的图像作为附件方法.

I think best practice is to use the embedded image as attachment method.

在我使用 Gmail 网络客户端进行的测试中,如果我在一封电子邮件中发送了 30 张不同大小的图片,其中一些图片将无法成功加载,但会显示图片容器而不是图片.如果发生这种情况,请尝试重新加载页面.

In my testing with Gmail Web Client, if I sent 30 images in a single email of different sizes, a few would not load successfully showing image container but not the image. If that happens, try reloading the page.

在我的测试中(Windows 7)...

In my testing (Windows 7)...

  • Chrome(最新)需要重新加载几次才能成功加载/显示所有 30 张图片
  • 无论重新加载多少次,Opera(最新)都无法成功显示所有 30 张图像
  • Firefox(最新版)始终如一地显示所有 30 张图片
  • Internet Explorer 9(最新)一致地显示所有 30 个图像,没有问题
  • Safari(最新)一致地显示所有 30 张图片,没有问题

这篇关于Base64 图像到 Gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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