.net - 在html电子邮件中嵌入附加图像

时间:2010-09-24 11:34:48

标签: asp.net vb.net

我有以下代码将图像附加到电子邮件中,但我需要将此图像嵌入到电子邮件的html中。

任何想法??

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>"

1 个答案:

答案 0 :(得分:0)

我认为这可以胜任,虽然它在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)