正常工作
嗨,我正在尝试通过 ASP.NET 将图片附件发送到某些电子邮件。该程序运行没有任何问题,但我无法在某些电子邮件程序中可视化附加的图片,例如iPhone的雅虎电子邮件程序。我怀疑我没有正确附上图片。它在我的台式电脑上工作正常
加载电子邮件时,我看不到图片。
Dim mail As New MailMessage()
mail.From = New MailAddress("xxxxxxxx", "xxxxxxx")
mail.To.Add(DirectCast(RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("Email"), TextBox).Text)
mail.Subject = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
mail.Body = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Dim htmlBody As String = "<html><body><DIV style=""background-color:#5B37AE"">"
htmlBody += "<img height=""70px"" width=""150px"" src=cid:HDIImage /></DIV></body></html>"
Dim htmlView As System.Net.Mail.AlternateView = System.Net.Mail.AlternateView.CreateAlternateViewFromString(htmlBody, Nothing, "text/html")
Dim imageResource As New System.Net.Mail.LinkedResource(Server.MapPath("~/Images/Site/background_main2.png"))
imageResource.ContentId = "HDIImage"
htmlView.LinkedResources.Add(imageResource)
mail.AlternateViews.Add(htmlView)
Dim j As New SmtpClient
j.Host = "hostingxxxxx"
j.EnableSsl = False
j.Credentials = New System.Net.NetworkCredential("usernam", "passw")
j.Send(mail)
谢谢
没有必要通过linkedresoruce附加,添加src="http://wwww.mysite.com/myimage.jpg"
在每个(现代)浏览器中都可以