vb.net 如何在电子邮件中嵌入 PDF?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/466741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:02:02  来源:igfitidea点击:

How can I embed a PDF in an email?

vb.netemailpdf

提问by Joe Morgan

I've already referred to this SO post. I've been embedding images using an AlternateView for PNG files. Now I'm wondering how to do it with PDFs.

我已经提到了这个 SO post。我一直在使用 AlternateView 为 PNG 文件嵌入图像。现在我想知道如何处理 PDF。

Should it work, for the LinkedResource, to just say:

对于 LinkedResource,它是否应该起作用,只需说:

Dim document As New LinkedResource(pdfFilePath, "image/pdf") 

I'm just trying to figure out how to get the PDF to be embedded like I could with an image, or is that not possible and I'll have to do it as an attachment?

我只是想弄清楚如何像嵌入图像一样嵌入 PDF,或者这是不可能的,我必须将其作为附件进行处理?

回答by DavGarcia

You can embed images since they can be rendered in place by an email client. PDFs cannot do that, so I'd recommend either having a thumbnail of the PDF that links to your web site with the actual PDF. Or just attach the PDF to the email message.

您可以嵌入图像,因为它们可以由电子邮件客户端就地呈现。PDF 无法做到这一点,因此我建议您使用 PDF 的缩略图链接到带有实际 PDF 的网站。或者只是将 PDF 附加到电子邮件中。

回答by Jas Panesar

There are a few options that I know of.

我知道有几个选项。

1) Is the simplest way okay?The easiest by far would be to attach the PDF as a normal attachment. Then render the first page of the pdf as an image, embed it in the email and link it to open the PDF if you can. Entourage kind of does this on the Mac.

1)最简单的方法好吗?到目前为止,最简单的方法是将 PDF 作为普通附件附加。然后将 pdf 的第一页渲染为图像,将其嵌入电子邮件中并链接它以打开 PDF(如果可以)。随行人员在 Mac 上执行此操作。

Alternatively, what I found was the following:

或者,我发现的是以下内容:

2) FLASHPAPERembedded in HTML displaying a PDF.Adobe has a technology called Flashpaper. It is a flash based file viewer. You can use flashpaper format documents that go into it, or PDFs as the source.

2)嵌入在 HTML 中的FLASHPAPER显示 PDF。Adobe 有一项称为Flashpaper的技术。它是一个基于 Flash 的文件查看器。您可以使用其中的 flashpaper 格式文档,或 PDF 作为源。

Check out some examples. That's really flash. http://www.adobe.com/products/flashpaper/examples/

查看一些示例。真的很闪啊 http://www.adobe.com/products/flashpaper/examples/

Assuming you send an HTML email that will get through (images aren't turned off, etc), you can can embed the Flashpaper viewer right in your HTML code as a normal Flash object.

假设您发送的 HTML 电子邮件可以通过(图像未关闭等),您可以将 Flashpaper 查看器作为普通 Flash 对象直接嵌入到您的 HTML 代码中。

Most HTML email clients use Internet Explorer Bits, Webkit bits, or Gecko bits to render the html. Flash player is pretty well installed on everything, so it works well. A good example of this is when we open an email and it has video playing in it. It's almost always Flash.

大多数 HTML 电子邮件客户端使用 Internet Explorer 位、Webkit 位或 Gecko 位来呈现 html。Flash 播放器在所有东西上都安装得很好,所以它运行良好。一个很好的例子是当我们打开一封电子邮件并在其中播放视频时。它几乎总是Flash。

I have had luck doing it this way -- the only thing you'd have to decide is if most of your clients can see this and how much (if any) today's software might block it.

我这样做很幸运——你唯一需要决定的是你的大多数客户是否可以看到这一点,以及今天的软件有多少(如果有)可能会阻止它。

What I ended up doing was a hybrid. 1) Attach it to the email, 2) Embed the Flashpaper viewer. They get it either way.

我最终做的是一个混合体。1) 将其附加到电子邮件中,2) 嵌入 Flashpaper 查看器。无论哪种方式,他们都会得到它。

Flashpaper is available seperately for $75. It has come in handy where the client was not able to install adobe acrobat on each computer and it had to be 100% web based.

Flashpaper 可单独购买,价格为 75 美元。它在客户端无法在每台计算机上安装 adobe acrobat 并且必须 100% 基于 Web 的情况下派上用场。

I would imagine you should be able to do the same using any language with a little more effort and using something like Flashpaper.

我想你应该能够使用任何语言和 Flashpaper 之类的东西来做同样的事情。

Hope that helps

希望有帮助

回答by Michael Haren

This is not possible--at least not in a way that will work with many clients. You'll need to just attach the file.

这是不可能的——至少不能与许多客户一起工作。您只需要附加文件即可。

If you have only one client to worry about, it mightbe possible--but not likely without manually changing settings on each client.

如果您只需要担心一个客户端,则可能有可能——但如果不手动更改每个客户端上的设置,则不太可能。

回答by Chris Nava

The MIME type of a PDF is "application/pdf" not "image/pdf"

PDF 的 MIME 类型是“application/pdf”而不是“image/pdf”