Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15705

VS 2019 I'm missing the text in my Mail.Body email.

$
0
0
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.
vb.net Code:
  1. Dim Mail As New MailMessage
  2. Mail.From = New MailAddress("sistemadecontrolmorelia@gmail.com", TextBox7.Text)
  3. Mail.[To].Add(New MailAddress(Enviar_a_Correo))
  4. Mail.Subject = TextBox7.Text
  5.  
  6. Dim img1 As LinkedResource = New LinkedResource("C:\Users\dante\Downloads\Black_Hole.jpg", MediaTypeNames.Image.Jpeg)
  7. img1.ContentId = "Image1"
  8. Mail.Body = Mail.Body & "<td><img src=cid:Image1 alt=></td>"
  9. Dim av1 As AlternateView = AlternateView.CreateAlternateViewFromString(Mail.Body, Nothing, MediaTypeNames.Text.Html)
  10. av1.LinkedResources.Add(img1)
  11. Mail.AlternateViews.Add(av1)
  12. Mail.IsBodyHtml = True
  13. Mail.Body = TextBox6.Text
  14.  
  15. Using SMTP As New SmtpClient("smtp.gmail.com")
  16.          SMTP.EnableSsl = True
  17.          SMTP.Credentials = New Net.NetworkCredential("myMail@gmail.com", "myPassword")
  18.          SMTP.Port = "587"
  19.          SMTP.Send(Mail)
  20. End Using

This is what the mail looks like.
Name:  Captura de pantalla 2021-01-19 221737.jpg
Views: 36
Size:  33.8 KB
Attached Images
 

Viewing all articles
Browse latest Browse all 15705

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>