EDN Admin
Well-known member
Alright, Ive been working on a quick project for school made with a 3rd party program. (Not visual basic express.) Basically Ive set it up to run a test at the end. It takes a screenshot of the test results, and saves it in the MyPictures folder.
Once its done taking the screenshot, it runs this visual basic program I have created. Its a very basic form for sending the screenshot to a teachers email address. Now here comes the part where I get trouble. Then I get it to delete the screenshot
of the test page after its deleted, so the person can retake the test, without having the screenshot being saved as screenshot(1).bmp so it will still send the photo in my visual basic program. What it does, is it freezes up a bit, normal. Then it unfreezes,
I get an email with the screenshot, but it doesnt delete the file, nor does it show a message box saying "All Done" that it should run. Its like after the email half of my code it just stops?
Here is my code so far:
<pre class="prettyprint lang-vb" style=" Imports System.Net.Mail
Public Class Form1
Dim smtp As New SmtpClient
Dim mail As New MailMessage
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyMailMessage As New MailMessage()
Try
Dim Attch As Net.Mail.Attachment = New Net.Mail.Attachment(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "TW.bmp")
MyMailMessage.Attachments.Add(Attch)
MyMailMessage.From = New MailAddress("gullible@mail.com")
MyMailMessage.To.Add("gullible@mail.com")
MyMailMessage.Subject = ("Thinking worlds pic")
MyMailMessage.Body = ("Yay")
Dim SMTP As New SmtpClient("smtp.mail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("gullible@mail.com", "gullible")
SMTP.Send(MyMailMessage)
Kill(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "TW.bmp")
MsgBox("All done!")
Catch ex As Exception
End Try
End Sub[/code]
<br/>
I have also tried it with a
<pre style="padding:5px <p style="font-family:Consolas,Courier,monospace; font-size:12px; line-height:16px <span style="color:blue My.Computer.FileSystem.DeleteFile <span style=" <span style="line-height:16px Instead of a Kill command. <span style=" <span style="line-height:16px Any idea why its not working? [/code]
<br/>
View the full article
Once its done taking the screenshot, it runs this visual basic program I have created. Its a very basic form for sending the screenshot to a teachers email address. Now here comes the part where I get trouble. Then I get it to delete the screenshot
of the test page after its deleted, so the person can retake the test, without having the screenshot being saved as screenshot(1).bmp so it will still send the photo in my visual basic program. What it does, is it freezes up a bit, normal. Then it unfreezes,
I get an email with the screenshot, but it doesnt delete the file, nor does it show a message box saying "All Done" that it should run. Its like after the email half of my code it just stops?
Here is my code so far:
<pre class="prettyprint lang-vb" style=" Imports System.Net.Mail
Public Class Form1
Dim smtp As New SmtpClient
Dim mail As New MailMessage
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyMailMessage As New MailMessage()
Try
Dim Attch As Net.Mail.Attachment = New Net.Mail.Attachment(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "TW.bmp")
MyMailMessage.Attachments.Add(Attch)
MyMailMessage.From = New MailAddress("gullible@mail.com")
MyMailMessage.To.Add("gullible@mail.com")
MyMailMessage.Subject = ("Thinking worlds pic")
MyMailMessage.Body = ("Yay")
Dim SMTP As New SmtpClient("smtp.mail.com")
SMTP.Port = 587
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("gullible@mail.com", "gullible")
SMTP.Send(MyMailMessage)
Kill(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "TW.bmp")
MsgBox("All done!")
Catch ex As Exception
End Try
End Sub[/code]
<br/>
I have also tried it with a
<pre style="padding:5px <p style="font-family:Consolas,Courier,monospace; font-size:12px; line-height:16px <span style="color:blue My.Computer.FileSystem.DeleteFile <span style=" <span style="line-height:16px Instead of a Kill command. <span style=" <span style="line-height:16px Any idea why its not working? [/code]
<br/>
View the full article