使用 SQL [sp_send_dbmail] 在电子邮件中嵌入图片
Embedding image in email with SQL [sp_send_dbmail]
我想使用 SQL 服务器将图像嵌入到 HTML 电子邮件中。
电子邮件正在发送,但图像不显示。
我的代码如下:
DECLARE @body_custom VARCHAR(MAX)
SET @body_custom = '<head>
<title> Embedded Logo Example</title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<table>
<tr>
<td valign="top" align="left">MyHeader</td>
</tr>
<tr>
<td valign="top" align="left">
<img src="image_1.jpg" width="235" height="70" alt="">
</td>
<tr>
<td valign="top" align="left">
<img src="image_2.png" width="235" height="70" alt="">
</td>
</tr>
<tr>
<td valign="top" align="left">
<img src="image_3.gif" width="235" height="70" alt="">
</td>
</tr>
</tr>
</table>
</body>'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Google_Gmail_Account'
, @recipients = '???@gmail.com'
, @subject = 'SQl 2008 R2 Email Test'
, @body = @body_custom
, @body_format = 'HTML'
, @file_attachments = 'C:\Users\User\Desktop\image_1.jpg;C:\Users\User\Desktop\image_2.png;C:\Users\User\Desktop\image_3.gif'
这会将电子邮件和图像作为附件发送,但它们不会显示在电子邮件中。
我也已将图像添加到我的 google 驱动器并获取了它们的链接并使用了它,但仍然没有成功...
经过一段时间的搜索和研究后,我发现我遇到的问题是电子邮件客户端的安全策略阻止我将图像嵌入到 HTML 格式的电子邮件中。
cid: img
以上标签确实有效,但由于安全策略的原因,无法通过发送 SSMS。
此问题的解决方案是将图像安全地托管在具有 SSL 证书的站点上;为所述图像生成直接 link 并将该 link 作为 html 图像标签内的来源。
我想使用 SQL 服务器将图像嵌入到 HTML 电子邮件中。 电子邮件正在发送,但图像不显示。 我的代码如下:
DECLARE @body_custom VARCHAR(MAX)
SET @body_custom = '<head>
<title> Embedded Logo Example</title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<table>
<tr>
<td valign="top" align="left">MyHeader</td>
</tr>
<tr>
<td valign="top" align="left">
<img src="image_1.jpg" width="235" height="70" alt="">
</td>
<tr>
<td valign="top" align="left">
<img src="image_2.png" width="235" height="70" alt="">
</td>
</tr>
<tr>
<td valign="top" align="left">
<img src="image_3.gif" width="235" height="70" alt="">
</td>
</tr>
</tr>
</table>
</body>'
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Google_Gmail_Account'
, @recipients = '???@gmail.com'
, @subject = 'SQl 2008 R2 Email Test'
, @body = @body_custom
, @body_format = 'HTML'
, @file_attachments = 'C:\Users\User\Desktop\image_1.jpg;C:\Users\User\Desktop\image_2.png;C:\Users\User\Desktop\image_3.gif'
这会将电子邮件和图像作为附件发送,但它们不会显示在电子邮件中。
我也已将图像添加到我的 google 驱动器并获取了它们的链接并使用了它,但仍然没有成功...
经过一段时间的搜索和研究后,我发现我遇到的问题是电子邮件客户端的安全策略阻止我将图像嵌入到 HTML 格式的电子邮件中。
cid: img
以上标签确实有效,但由于安全策略的原因,无法通过发送 SSMS。
此问题的解决方案是将图像安全地托管在具有 SSL 证书的站点上;为所述图像生成直接 link 并将该 link 作为 html 图像标签内的来源。