简体   繁体   English

如何在SSRS电子邮件报告中包含内联(未链接)图像?

[英]How to include inline (not linked) images in SSRS e-mail reports?

I have multiple SSRS 2008 report templates that contain embedded images and these are currently visible as expected in any report manager previews (using rendering extension HTML 4.0). 我有多个包含嵌入图像的SSRS 2008报告模板,这些模板当前在任何报告管理器预览中都是可见的(使用渲染扩展HTML 4.0)。 However, I need these reports to be sent out as HTML e-mails. 但是,我需要将这些报告作为HTML电子邮件发送出去。

I believe the basic/easiest technique here is to attach the images as inline base64 string to the image tags in the HTML. 我相信这里最基本/最简单的技术是将图像作为内联base64字符串附加到HTML中的图像标记。 Is there a way to do this automatically in SSRS or alternatively what is the best practice to achieve this or similar result (ie images as attachments resulting in not-too-interoperable MHTML instead of pure HTML)? 有没有办法在SSRS中自动执行此操作,或者实现此类结果或类似结果的最佳实践是什么(即图像作为附件导致MHTML不能互操作而不是纯HTML)?

The e-mail must be displayed as-is without connecting to any external storage (ie it's not feasible to host the images by the sender). 电子邮件必须按原样显示,而不连接任何外部存储(即发送者无法托管图像)。 Additionally we won't be using the SSRS itself to send the resulting HTML/e-mails so any restrictions of such nature are not of concern. 此外,我们不会使用SSRS本身发送生成的HTML /电子邮件,因此任何此类性质的限制都不会受到关注。

Example of the inline base64 I was thinking: 内联base64的例子我在想:

<img src="data:image/png;base64,xxxxxxxx==" alt="Some Image">

It appears that the easiest way to achieve this is to modify or extend the rendering extension just a tiny bit as described in the MSDN documentation : 似乎最简单的方法是修改或扩展渲染扩展,如MSDN文档中所述

Writing Custom Rendering Extensions 编写自定义渲染扩展

Before you decide to create a custom rendering extension, you should evaluate simpler alternatives. 在决定创建自定义呈现扩展插件之前,您应该评估更简单的替代方案。 You can: 您可以:

  1. Create a modified version of an existing rendering extension. 创建现有渲染扩展的修改版本。
  2. Customize rendered output by specifying device information settings for existing extensions. 通过指定现有扩展的设备信息设置来自定义渲染输出。
  3. Add custom formatting and presentation features by combining XSL Transformations (XSLT) with the output of the XML rendering format. 通过将XSL转换(XSLT)与XML呈现格式的输出相结合,添加自定义格式和表示功能。

Writing a custom rendering extension is difficult to do as well as to learn.. A rendering extension must typically support all possible combination of report elements. 编写自定义渲染扩展很难做到和学习。渲染扩展通常必须支持所有可能的报表元素组合。 The report object model is extensive (the classes, interfaces, methods, and properties that you must implement number in the hundreds), and the documentation and samples are not yet at a level that can support you through a challenging development project. 报表对象模型非常广泛(必须实现数百个的类,接口,方法和属性),并且文档和示例尚未达到可以支持您完成具有挑战性的开发项目的级别。

If you must render a report in a format that is not included with Reporting Services, you can write your own managed code implementation of a rendering extension. 如果必须以Reporting Services中未包含的格式呈现报表,则可以编写自己的呈现扩展插件代码实现。 The rendering extension code must implement the IRenderingExtension interface, which is required by the report server. 呈现扩展代码必须实现报告服务器所需的IRenderingExtension接口。 Each of the rendering extensions implemented by Microsoft and shipped with Reporting Services uses a common set of interfaces. Microsoft实现并随Reporting Services一起提供的每个呈现扩展都使用一组通用接口。 This ensures that each extension implements comparable functionality and reduces the complexity of the rendering code in the core of the report server. 这可确保每个扩展实现可比较的功能,并降低报表服务器核心中呈现代码的复杂性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM