简体   繁体   English

使用具有嵌入图像的经典ASP发送电子邮件

[英]Send Email Using Classic ASP with an Embeded Image

i am making NewsLetter using the wysiwyg Editor.. it allows me to upload the Image Path and Image Path is stored in the Upload Directory.. Not When i retrieve that Image using it works in website.. the editor's value is stored in database example <br> hi 我正在使用所见即所得的编辑器制作NewsLetter ..它允许我上传图像路径,并且图像路径存储在上载目录中。.不是当我使用它在网站上检索该图像时..编辑器的值存储在数据库示例中<br>

<img src="upload/acb.gif">

<br>

Hello 你好

i am sending Email and the detail of this email is received from database and this detail is sent to visitor 我正在发送电子邮件,并且已从数据库接收到此电子邮件的详细信息,并将此详细信息发送给访问者

he is gettion all text value but not able to see Image 他正在获取所有文本值,但看不到图像

so suggest me what to do..? 所以建议我该怎么办..?

If you are sending emails using CDOSYS.Message, you can easily send a complete web page with embedded images using the Message.CreateMHTMLBody(url) method. 如果使用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; 我最近清理了一些我要做的代码,并在github上以“ Gist”的形式在线拍了拍; hope it still helps someone! 希望它能对某人有所帮助!

Sending embedded images with CDOSYS 使用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. 此解决方案使用带有“ AddAttachment”的CDO(CDOSYS / CDO.Message),并手动控制附件的属性,以使附件在电子邮件HTML中可用,并避免它们在电子邮件客户端中显示为可单独下载的附件。

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: 用法非常简单,只需通过消息HTML中的本地路径(在运行代码的计算机上)引用图像,例如:

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. 该代码将选择文件名,将文件添加为邮件的附件,并使用对该附件的内部引用替换邮件HTML的相关部分。

You would have to add site url to img source 您必须将网站网址添加到img源

<img src="http://www.sitename.com/upload/acb.gif"> as the user is not accessing your site from his mailbox. <img src =“ http://www.sitename.com/upload/acb.gif”>,因为用户没有从他的邮箱访问您的网站。

For this you can set " http://www.sitename.com/ " as a key in web.config and use in your mails. 为此,您可以在web.config中将“ http://www.sitename.com/ ”设置为密钥,并在邮件中使用。

This will resolve your problem for sure. 这肯定会解决您的问题。 Happy coding !!!!!!!!!!!!! 祝您编码愉快!

You would use AddRelatedBodyPart: 您将使用AddRelatedBodyPart:

Embed Usage Create Array and Pass it in "SendMail" Function as Parameter Use in Email Body eg 嵌入用法创建数组并将其作为电子邮件正文中的参数使用传递给“ SendMail”函数

Dim arrRelatedBodyPart(1)
arrRelatedBodyPart(0) = Server.MapPath(".") & "/images/barcode/bar_blk.gif"
arrRelatedBodyPart(1) = Server.MapPath(".") & "/images/barcode/bar_wht.gif"

Example

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

What are you using to send the email, I have had success in the past using AspEmail: http://www.aspemail.com/ 您使用什么来发送电子邮件,过去我使用AspEmail取得了成功: http : //www.aspemail.com/

It explains how to send embedded images here: http://www.aspemail.com/manual_04.html 它说明了如何在此处发送嵌入的图像: http : //www.aspemail.com/manual_04.html

However you will have to get it installed on your server, if you are using Shared hosting this might be a problem, if you are running your own server pretty easy! 但是,如果您使用共享主机,则必须将其安装在服务器上,如果您很容易地运行自己的服务器,则可能会出现问题!

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

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