如何将图像嵌入html并通过msdb.dbo.sp_send_dbmail作为电子邮件发送html? [英] How to embed image in html and send html as email by msdb.dbo.sp_send_dbmail?

查看:185
本文介绍了如何将图像嵌入html并通过msdb.dbo.sp_send_dbmail作为电子邮件发送html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用msdb.dbo.sp_send_dbmail以html格式发送电子邮件.仅在格式方面对文本非常好.例如:

I can use msdb.dbo.sp_send_dbmail to send out email in html format. It is very nice for text only in terms of format. For example:

EXEC msdb.dbo.sp_send_dbmail
  @recipients = @p_recipients,
  @subject = @v_subject,
  @body=@emailHTML, 
  @body_format = 'HTML';

但是,如果要在SQL服务器上包括从数据生成的趋势之类的图像并将其嵌入html(@emailHTML)中,应该使用哪个html标签?

However, if I want to include images such as trend generated from data on my SQL server, and to embed them in the html (@emailHTML), what html tag should I use?

如果我使用[img]标记,则需要设置src属性.生成的图像保存在本地SQL Server的硬盘中.我可以将它们放在IS服务器网页区域中.但是所有这些Web服务器都可以通过Intranet访问,但不是在我的工作范围之外.

If I use [img] tag, then I need to set the src attribute. The image generated are saved in my local SQL server's hard disk. I could place them in IS server web page area. But all those web servers are intranet accessible but not outside of my work.

有什么方法可以在电子邮件中嵌入图像?如何设置html嵌入图像?

Is there any way to embed image in the email? How I can set html to embed images?

我正在使用Microsoft SQL Server2005.我更喜欢msdb.dbo.sp_send_dbmail来将报告作为电子邮件发送出去.我对html格式有很多控制权.如果没有办法,我可能必须将图像作为附件发送.

I am using Microsoft SQL server 2005. I prefer to msdb.dbo.sp_send_dbmail to send out reports out as email. I have much control of html format. If there is no way to that, I may have to send images as attachment files.

推荐答案

我想我得到了答案:

EXEC msdb.dbo.sp_send_dbmail
   @recipients = 'myemail@someemail.com',
   @subject = 'test',
   @file_attachments = 'C:\MyFolder\Test\Google.gif;C:\MyFolder\Test\Yahoo.gif',
   @body=N'<p>Image Test</p><img src="Google.gif" /><p>See image there?</p>
        <img src="Yaoo.gif" /><p>Yahoo!</p>', 
   @body_format = 'HTML';

基本上,将图像添加为附件,并且src属性仅包含图像文件名,不需要任何路径.如果需要多个图像文件,只需使用;"分开它们.

basically, add the image as attachment, and the src attribute contains just the image file name, no any path is needed. If more than one image files are needed, just use ";" to separate them.

我将电子邮件发送到我的Outlook电子邮件,并且可以使用.尝试到我的Yahoo电子邮件....

I send email to my outlook email and it works. Try it to my yahoo email....

这篇关于如何将图像嵌入html并通过msdb.dbo.sp_send_dbmail作为电子邮件发送html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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