0

I have my PrintDocument1_PrintPage like this:

Dim x As Single = e.MarginBounds.Left
Dim y As Single = e.MarginBounds.Top
Dim bmp As New Bitmap(Me.GroupBox3.Width, Me.GroupBox3.Height)
Me.GroupBox3.DrawToBitmap(bmp, New Rectangle(0, 0, Me.GroupBox3.Width, Me.GroupBox3.Height))
e.Graphics.DrawImage(DirectCast(bmp, Image), x, y)

Then, I have to send an simple email with this bitmap in the body and I don't know how to do it.

e_mail = New MailMessage()
e_mail.From = New MailAddress("mail@gmail.com")
e_mail.To.Add(MailBox1.Text)
e_mail.Subject = "Subject here"
e_mail.IsBodyHtml = False
e_mail.Body =   I WANT TO ADD THE PREVIOUS BITMAP HERE.
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")

Thank you!

  • 3
    Possible duplicate of [C# Attaching System.Drawing.Image to Email](https://stackoverflow.com/questions/21688300/c-sharp-attaching-system-drawing-image-to-email) – GSerg Jun 06 '20 at 17:15
  • 3
    Possible duplicate of [Attaching a screenshot to new email outlook image with vb net](https://stackoverflow.com/q/42641269/11683) – GSerg Jun 06 '20 at 17:16
  • Though I'm not sure I'd use this GDI in a production server environment. Have you considered ImageMagick or similar? – Caius Jard Jun 06 '20 at 17:18
  • @CaiusJard There's a winforms program involved that screenshots a part of its own form. The GDI is already baked in. – GSerg Jun 06 '20 at 17:32
  • ... and [Adding Image to System.Net.Mail Message](https://stackoverflow.com/a/19911249/10216583) if you want to display the image rather than attach it... –  Jun 06 '20 at 22:47

0 Answers0