Hello!
I'm trying to send an email from a windows form application using VB.NET. the email contains some text and an embedded image. I get to send the image, but the text is totally missing, my Mail.Body comes from a TextBox in this case is the TextBox6.Text
This is my code so far.
This is what the mail looks like.
![Name: Captura de pantalla 2021-01-19 221737.jpg
Views: 36
Size: 33.8 KB]()
I'm trying to send an email from a windows form application using VB.NET. the email contains some text and an embedded image. I get to send the image, but the text is totally missing, my Mail.Body comes from a TextBox in this case is the TextBox6.Text
This is my code so far.
vb.net Code:
Dim Mail As New MailMessage Mail.From = New MailAddress("sistemadecontrolmorelia@gmail.com", TextBox7.Text) Mail.[To].Add(New MailAddress(Enviar_a_Correo)) Mail.Subject = TextBox7.Text Dim img1 As LinkedResource = New LinkedResource("C:\Users\dante\Downloads\Black_Hole.jpg", MediaTypeNames.Image.Jpeg) img1.ContentId = "Image1" Mail.Body = Mail.Body & "<td><img src=cid:Image1 alt=></td>" Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(Mail.Body, Nothing, MediaTypeNames.Text.Html) av1.LinkedResources.Add(img1) Mail.AlternateViews.Add(av1) Mail.IsBodyHtml = True Mail.Body = TextBox6.Text Using SMTP As New SmtpClient("smtp.gmail.com") SMTP.EnableSsl = True SMTP.Credentials = New Net.NetworkCredential("myMail@gmail.com", "myPassword") SMTP.Port = "587" SMTP.Send(Mail) End Using
This is what the mail looks like.