1
我試圖在電子郵件正文中顯示一個嵌入圖像。這是發送,但沒有圖像。使用vb.net在emaill中不顯示嵌入圖像
下面是代碼:
Dim mail As New MailMessage()
mail.[To].Add("[email protected]")
mail.From = New MailAddress("[email protected]")
mail.Subject = "Test Email"
Dim Body As String = "<b>Welcome to codedigest.com!!</b><br><BR>Online resource for .net articles.<BR><img alt="""" hspace=0 src=""cid:imageId"" align=baseline border=0 >"
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(Body, Nothing, "text/html")
Dim imagelink As New LinkedResource(Server.MapPath(".") & "\uploads\CIMG1443.JPG", "image/jpg")
imagelink.ContentId = "imageId"
imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64
htmlView.LinkedResources.Add(imagelink)
mail.AlternateViews.Add(htmlView)
Dim smtp As New SmtpClient()
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis
smtp.Host = ConfigurationManager.AppSettings("SMTP")
smtp.Port = 587
'smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential(ConfigurationManager.AppSettings("FROMEMAIL"), ConfigurationManager.AppSettings("FROMPWD"))
smtp.Send(mail)
在電子郵件的正文中只有以下是顯示:
歡迎CodeDigest.Com!
任何想法如何讓CIMG1443.JPG顯示?
感謝
可惜,我也需要一個答案。 :) – 2011-12-07 13:02:31