我正在使用所见即所得的编辑器制作 NewsLetter。它允许我上传图像路径,图像路径存储在上传目录中。当我使用它在网站上检索该图像时,编辑器的值存储在数据库示例中
<br>
你好
<img src="upload/acb.gif">
<br>
你好
我正在发送电子邮件,这封电子邮件的详细信息是从数据库中收到的,此详细信息将发送给访问者
他正在获取所有文本值但看不到图像
所以建议我该怎么做..?
我正在使用所见即所得的编辑器制作 NewsLetter。它允许我上传图像路径,图像路径存储在上传目录中。当我使用它在网站上检索该图像时,编辑器的值存储在数据库示例中
<br>
你好
<img src="upload/acb.gif">
<br>
你好
我正在发送电子邮件,这封电子邮件的详细信息是从数据库中收到的,此详细信息将发送给访问者
他正在获取所有文本值但看不到图像
所以建议我该怎么做..?
如果您使用 CDOSYS.Message 发送电子邮件,则可以使用 Message.CreateMHTMLBody(url) 方法轻松发送包含嵌入图像的完整网页。
Dim Message
Set Message = CreateObject("CDOSYS.Message")
Message.From = "from@email.org"
Message.To = "to@email.org"
Message.CreateMTHMLBody "http://yourserver.org/email.html"
Message.Send()
I recently cleaned up some code I had lying around to do this and slapped it online as a "Gist" on github; hope it still helps someone!
Sending embedded images with CDOSYS
This solution uses CDO (CDOSYS / CDO.Message), with "AddAttachment", and manually controlling the properties of the attachments to make them usable from within the email HTML and to avoid them appearing as separately-downloadable attachments in an email client.
The usage is very simple, just reference the images by a local path (on the computer the code is running on) in the HTML of the message, eg:
Some Image: <img src="<EMBEDDEDIMAGE:C:\test.jpeg>" />
The code will pick up the filename, add the file as an attachment to the message, and replace the relevant part of the message HTML with the internal reference to that attachment.
您必须将网站网址添加到 img 源
<img src="http://www.sitename.com/upload/acb.gif"> 因为用户没有从他的邮箱访问您的网站。
为此,您可以将“ http://www.sitename.com/ ”设置为 web.config 中的键并在您的邮件中使用。
这肯定会解决您的问题。编码快乐!!!!!!!!!!!!!
您将使用 AddRelatedBodyPart:
嵌入用法 创建数组并将其传递给“SendMail”函数作为电子邮件正文中的参数使用,例如
Dim arrRelatedBodyPart(1)
arrRelatedBodyPart(0) = Server.MapPath(".") & "/images/barcode/bar_blk.gif"
arrRelatedBodyPart(1) = Server.MapPath(".") & "/images/barcode/bar_wht.gif"
例子
For i = 0 To UBound(arrRelatedBodyPart)
Dim strPathAndFileName: strPathAndFileName = arrRelatedBodyPart(i)
Dim strFileName: strFileName = GetFileName(arrRelatedBodyPart(i), "/")
'.AddRelatedBodyPart strPathAndFileName, strFileName, cdoRefTypeId
Set objCDOBodyPart = .AddRelatedBodyPart(strPathAndFileName, strFileName, 1)
objCDOBodyPart.Fields.Item("urn:schemas:mailheader:Content-ID") = "<" & strFileName & ">"
objCDOBodyPart.Fields.Update
Next
你用什么来发送电子邮件,我过去使用 AspEmail 取得了成功:http ://www.aspemail.com/
它解释了如何在此处发送嵌入的图像:http ://www.aspemail.com/manual_04.html
但是,您必须将它安装在您的服务器上,如果您使用共享主机,这可能是一个问题,如果您运行自己的服务器非常容易!