.net - embedding attached image in html email
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.
Any ideas??
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' /> <开发者_JAVA技巧p>with this email</p>"
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)
精彩评论