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 = bodycodice 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

Rispondi quotando
