He everyone.
I'm trying to add the PictureBox1 Image into my email body when i click on a Button, but without any results.
The picture is not something that was saved on my hard drive, so no real file attachment.
It does not fail with the code i have, but it does not add the picture either. So this is my problem.
How can i make it work?
Thanks again for your help
Here is my code:
I'm trying to add the PictureBox1 Image into my email body when i click on a Button, but without any results.
The picture is not something that was saved on my hard drive, so no real file attachment.
It does not fail with the code i have, but it does not add the picture either. So this is my problem.
How can i make it work?
Thanks again for your help
Here is my code:
Code:
Private Function TakeScreenShot(ByVal Control As Control) As Bitmap
Dim tmpImg As New Bitmap(Control.Width, Control.Height)
Using g As Graphics = Graphics.FromImage(tmpImg)
g.CopyFromScreen(PictureBox1.PointToScreen(New Point(0, 0)), New Point(0, 0), New Size(PictureBox1.Width, PictureBox1.Height))
End Using
Return tmpImg
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim Outlook As Outlook.Application
Dim Mail As Outlook.MailItem
Dim Acc As Outlook.Account
Outlook = New Outlook.Application()
Mail = Outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
Mail.To = "test@test.ca"
Mail.Subject = "Please review"
'If you have multiple accounts you could change it in sender:
For Each Acc In Outlook.Session.Accounts
'Select first pop3 for instance.
If Acc.AccountType = Microsoft.Office.Interop.Outlook.OlAccountType.olPop3 Then
Mail.Sender = Acc
End If
Next
'Attach files
' Mail.Attachments.Add("C:\Path\To\File1.pdf")
'Append some text:
Mail.HTMLBody &= "<span style='font-family:calibri,serif;'>
<span style='font-size: 22px;'><strong>
<span style='color: #1e398a'>PICTURE</span> -> <span style='font-family:calibri,serif;'>
<span style='font-size: 22px;'>below</span>
</strong>" & "<br><br>
<img src=TakeScreenShot(PictureBox1)>"
Mail.Display()
End Sub