Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    send embed image with vb.net by code error image base64

    hello, I have a little program made in vb.net visual basic that sends timed emails. I would like to insert an image in the email in base64 format. I did some tests but the image never gets inserted. here is part of the code:
    codice HTML:
      Dim imageUrl As String = GetImageUrl("C:\Users\conce\Desktop\Logo_orizzontale.png")
                    Dim imageContent As String = "<img src='" + imageUrl + "'  />"
                    Dim body As String = "TEST,<br /><br />Welcome to ....<br /><br />" & imageContent & "<br/><br/>Thanks."
    
                    .HTMLBody = body
    codice HTML:
    Private Function GetImageUrl(ByVal imagePath As String) As String
            Dim image As System.Drawing.Image = System.Drawing.Image.FromFile(imagePath)
            Dim memoryStream As MemoryStream = New MemoryStream()
            image.Save(memoryStream, ImageFormat.Png)
            Dim bytes As Byte() = New Byte(memoryStream.Length - 1) {}
            memoryStream.Position = 0
            memoryStream.Read(bytes, 0, CInt(bytes.Length))
            Dim base64String As String = Convert.ToBase64String(bytes, 0, bytes.Length)
            Dim imageUrl As String = "data:image/png;base64," & base64String
    
            Return imageUrl
        End Function

  2. #2
    Utente di HTML.it L'avatar di supermac
    Registrato dal
    Jun 2001
    Messaggi
    1,881
    Have you already checked the body string generated?
    Here you can test if the generated base64 string imageUrl is correct or not
    https://www.base64decode.org/
    W la Ferari effetrenavenave!
    il computer è un somaro veloce! (neanche tanto ndr)

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.