(我使用的是C#,而不是VB.NET)
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient "myRecipient@hisdomain.com", "Mr.Example"
jmail.From = "me@mydomain.com"
jmail.Subject = "Here's some graphics!"
jmail.Body = "A nice picture if you can read HTML-mail."
' The return value of AddAttachment is used as a
' reference to the image in the HTMLBody.
contentId = jmail.AddAttachment("c:\myCoolPicture.gif")
' As only HTML formatted emails can contain inline images
' we use HTMLBody and appendHTML
jmail.HTMLBody = "<html><body><font color=""red"">Hi, here is a nice picture:</font><br>"
jmail.appendHTML "<img src=""cid:" & contentId & """>"
jmail.appendHTML "<br><br>good one huh?</body></html>"
' But as not all mailreaders are capable of showing HTML emails
' we will also add a standard text body
jmail.Body = "Too bad you can't read HTML-mail."
jmail.appendText " There would have been a nice picture for you"
jmail.Send( "mailserver.mydomain.com" )
这是我通过jmail发送html电子邮件的唯一例子。
但正如你在这里看到的那样,它是一个图像文件。
我的情况是我会生成一张图片并直接发送,而不将其保存为文件。
那么我能为此目的做些什么吗? 我真的不想保存它然后发送然后删除它.....
非常感谢
答案 0 :(得分:1)
有一种方法......使用嵌入式base64 CSS3图像,如:
.myImage {background: url(data:image/gif;base64,R0lGODlhBgASALM...)}
并在HTML代码中将其作为DIV标记引用。根本不需要保存任何文件。
答案 1 :(得分:0)
似乎没有其他选择,只能将其保存为文件并发送,然后将其删除....
我会在这篇文章中再发几天,看看是否有可能解决这个问题。