.mail Attachment Error
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
10 posts
Page 1 of 1
Hello again ones again my stupidity brings me to the smart people of the world i am trying to attack an
image of a picturebox to an email in vb.net but well it isnt working when done hopefully i will be able to
attack a screen print of a panel so it takes a pic of all the controlls in the panel as well and emails that
but anyway here is what i am getting
![Image]()
image of a picturebox to an email in vb.net but well it isnt working when done hopefully i will be able to
attack a screen print of a panel so it takes a pic of all the controlls in the panel as well and emails that
but anyway here is what i am getting

You have to save the image, and then you can do this:
Code: Select all
Dim att as New System.Net.Mail.Attachment("image filename")
mail.Attachments.Add(att)
muttley1968 wrote:Hello again ones again my stupidity brings me to the smart people of the world i am trying to attack anThe attack an image is kinda funny, no hard feelings
image of a picturebox to an email in vb.net but well it isnt working when done hopefully i will be able to
attack a screen print of a panel so it takes a pic of all the controlls in the panel as well and emails that
but anyway here is what i am getting

Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
hahaha i did mean atached yes sorry my bad and neither of them codes work as i cant save the image because its supposed to be autmated so unless there is a way to make it save its self to temp data or something i cant do that any ideas how i can fix this to just send the pictureboxes image over
There is no reason why the image has to be saved.
You can attach it from a stream with this:
You can attach it from a stream with this:
Code: Select all
Dim ms As MemoryStream = New MemoryStream()
PictureBox1.Image.Save(ms, ImageFormat.Png)
ms.Position = 0
Dim a As Attachment = New Attachment(ms, "test.png")
mail.Attachments.Add(a)
Thanks Mandai that work amazingly good but does anyone know how to take a screen shot of a panel and all its controls and then apply that image as the image of a picturebox :P
You could use this:
Code: Select all
Panel1.DrawToBitmap(PictureBox1.Image, New Rectangle(0, 0, Panel1.Width, Panel1.Height))
i tired to use that code and it said "Value cannot be null. Parameter name: bitmap" and wouldnt work
You can set the picturebox image variable with this:
Code: Select all
PictureBox1.Image = New Bitmap(Panel1.Width, Panel1.Height)
it doesnt work now it just does nothing know errors or anything but nothing happens
no errors no nothing
no errors no nothing
10 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023