Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image not showing in vb.net

Image not showing in vb.net

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-netvisual-studio
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 8761667
    wrote on last edited by
    #1

    Hello I have partly followed this tutorial: Sending email with an embedded image through ASP.NET[^] and, though the user receives his email, when I test my SMTP locally, the plain background image (600px x 600px) does not appear. In Visual Studio (2013), I don't get any errors. The image, emailBG.jpg, is in my Images folder in Solution Explorer, and the code I am using to send plain and HTML emails, and for the background image, is as follows:

    Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password....Nothing, "text/plain")
    Dim mimeType As ContentType = New ContentType("text/html")
    Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("

    pre> Thanks for any advice.

    L Richard DeemingR 2 Replies Last reply
    0
    • M Member 8761667

      Hello I have partly followed this tutorial: Sending email with an embedded image through ASP.NET[^] and, though the user receives his email, when I test my SMTP locally, the plain background image (600px x 600px) does not appear. In Visual Studio (2013), I don't get any errors. The image, emailBG.jpg, is in my Images folder in Solution Explorer, and the code I am using to send plain and HTML emails, and for the background image, is as follows:

      Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password....Nothing, "text/plain")
      Dim mimeType As ContentType = New ContentType("text/html")
      Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("

      pre> Thanks for any advice.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please post your question in the forum at the end of the article, so the author sees it.

      M 1 Reply Last reply
      0
      • L Lost User

        Please post your question in the forum at the end of the article, so the author sees it.

        M Offline
        M Offline
        Member 8761667
        wrote on last edited by
        #3

        Hello Richard Thanks for your reply. The article is 10 years old - not sure if the author will even see it. Thanks again.

        1 Reply Last reply
        0
        • M Member 8761667

          Hello I have partly followed this tutorial: Sending email with an embedded image through ASP.NET[^] and, though the user receives his email, when I test my SMTP locally, the plain background image (600px x 600px) does not appear. In Visual Studio (2013), I don't get any errors. The image, emailBG.jpg, is in my Images folder in Solution Explorer, and the code I am using to send plain and HTML emails, and for the background image, is as follows:

          Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password....Nothing, "text/plain")
          Dim mimeType As ContentType = New ContentType("text/html")
          Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("

          pre> Thanks for any advice.

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          Looks like the HTML version of your message has been truncated, so we can't see what styles you've applied. And remember, if you're setting a background image for a <p> tag, it will be cropped to the site of that paragraph of text. You probably want to specify the <body> tag, and put the background image there:

          Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<body style=""background:url('cid:emailBG') no-repeat;"">...</body>", Nothing, "text/html")


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          M 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            Looks like the HTML version of your message has been truncated, so we can't see what styles you've applied. And remember, if you're setting a background image for a <p> tag, it will be cropped to the site of that paragraph of text. You probably want to specify the <body> tag, and put the background image there:

            Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<body style=""background:url('cid:emailBG') no-repeat;"">...</body>", Nothing, "text/html")


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            M Offline
            M Offline
            Member 8761667
            wrote on last edited by
            #5

            Yes, you're right. I do have that against 'p' at the moment:

            ("

            Hello " & strEmailValue & "

            To reset your password....etc

            ", Nothing, "text/html")

            I will take on board what you suggest about 'body' as opposed to 'p' and use your 'cid:email.BG'. Would I still need these two lines that follow the above line I have posted above:

            Dim Logo As New LinkedResource(Server.MapPath("~/Images/emailBG.jpg"), "image/jpeg") 'embedded image
            Logo.ContentId = "emailBG"

            Isn't 'Logo.ContentId = "emailBG"' a repetition of your 'cid:emailBG'? Thanks. Can you see this message though it is not in 'Preview'?

            Richard DeemingR 1 Reply Last reply
            0
            • M Member 8761667

              Yes, you're right. I do have that against 'p' at the moment:

              ("

              Hello " & strEmailValue & "

              To reset your password....etc

              ", Nothing, "text/html")

              I will take on board what you suggest about 'body' as opposed to 'p' and use your 'cid:email.BG'. Would I still need these two lines that follow the above line I have posted above:

              Dim Logo As New LinkedResource(Server.MapPath("~/Images/emailBG.jpg"), "image/jpeg") 'embedded image
              Logo.ContentId = "emailBG"

              Isn't 'Logo.ContentId = "emailBG"' a repetition of your 'cid:emailBG'? Thanks. Can you see this message though it is not in 'Preview'?

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Yes, you'd still need the linked resource. The cid: is the protocol which lets the mail client know that the image should be loaded from the linked resources in the message, rather than trying to load it from a file or a website. So cid:emailBG in the HTML is a URL that points to the embedded resource with the content ID set to emailBG. How do I embed images in an email?[^]


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              M 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                Yes, you'd still need the linked resource. The cid: is the protocol which lets the mail client know that the image should be loaded from the linked resources in the message, rather than trying to load it from a file or a website. So cid:emailBG in the HTML is a URL that points to the embedded resource with the content ID set to emailBG. How do I embed images in an email?[^]


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                M Offline
                M Offline
                Member 8761667
                wrote on last edited by
                #7

                Thanks. I am familiar with that link - been hours on this! I will give it all a go and fingers crossed! Many thanks again for your help.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups