.net - 在 html 电子邮件中嵌入附加图像 [英] .net - embedding attached image in html email
本文介绍了.net - 在 html 电子邮件中嵌入附加图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码将图像附加到电子邮件中,但我需要将此图像嵌入到电子邮件的 html 中.
I have the following code which attaches an image to the email but I need this image to be embedded in the html of the email.
有什么想法吗??
objMM.Attachments.Add(new MailAttachment(Server.MapPath("images1/links/beach-icon.jpg")))
objMM.Body = "<p>There should be an attachment</p> <img src='beach-icon.jpg' /> <p>with this email</p>"
推荐答案
我认为这样做可以,尽管它在 Mac OSX 的 Mail 中不起作用
I think this does the job, though it doesn't work in Mail for Mac OSX
Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", Nothing, "text/plain")
Dim logo As New LinkedResource(Server.MapPath("images1/links/beach-icon.jpg"))
logo.ContentId = "embeddedimage"
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<p>Here is an embedded image.</p> <img src=cid:embeddedimage> <p>More text here</p>", Nothing, "text/html")
htmlView.LinkedResources.Add(logo)
objMM.AlternateViews.Add(plainView)
objMM.AlternateViews.Add(htmlView)
这篇关于.net - 在 html 电子邮件中嵌入附加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文