0

您好我正在尝试通过 ASP.NET 将图片附件发送到某些电子邮件。该程序运行没有任何问题,但我无法在某些电子邮件程序中可视化附件图片,例如 iPhone 的 Yahoo 电子邮件电子邮件程序。我怀疑我没有正确附加图片。它在我的台式电脑上工作正常

加载电子邮件时,我看不到图片。

   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)

谢谢

4

1 回答 1

1

没有必要通过linkedresoruce附加,src="http://wwww.mysite.com/myimage.jpg"在每个(现代)浏览器中添加都可以

于 2012-07-02T17:10:01.270 回答