0

Hi I am trying to send a picture attachment to some email via ASP.NET. The program works without any problem, but I cannot visualize the attached picture in some email programs, such as iPhone's email program for Yahoo email. I suspect I am not attaching correctly the picture. It works ok on my desktop pc

When the email is loaded I cannot see the picture.

   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)

Thanks

2
  • email clients have setting to enable and disable html in msgs, first step is to check for that setting.
    – Zia
    Commented Jul 2, 2012 at 9:18
  • 1
    Rewrite your question's title in more concrete phrases avoiding word "issue", please. Commented Jul 2, 2012 at 14:39

1 Answer 1

1

It was not necessary to attach via linkedresoruce, adding src="http://wwww.mysite.com/myimage.jpg" works ok in every (modern) browser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.