How to Shutdown/Lock your computer via Email

Sometimes you might think to shutdown your PC from a remote location. If so, then don't panic here & there in search engines. Today I am going to tell you a cool and easiest trick to shutdown/lock/logoff/restart your computer just by sending a simple mail. Just read the following steps.

What you need for this ?


You need MS Outlook for this and you have to copy-paste some Visual Basic codes. If you don't know what is MS Outlook then click here.

How to do it ?

  • Configure your email account in MS Outlook.
  • Then press alt+f11 to open the Visual Basic editor.
  • In that editor there will be a button Macro Seurity. Click on it, a window will open. Then click on the radio button No security check for macro.
  • Then open the Project1 present in the left side vertical bar, then double click on ThisOutlookSession to view the code. If anything is previously written then delete them.
  • Then copy and paste the following code in that visual basic editor.
Private Declare Function LockWorkStation Lib "user32.dll" () As Long
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
 Dim EntryID
 Dim lastItem
 EntryID = Split(EntryIDCollection, ",")
 For i = 0 To UBound(EntryID)
    Set lastItem = Application.Session.GetItemFromID(EntryID(i))
    If (LCase(lastItem.Subject) = "shutdown") Then
        Call Shell("Shutdown /s")
    End If
    If (LCase(lastItem.Subject) = "logoff") Then
        Call Shell("Shutdown /l")
    End If
    If (LCase(lastItem.Subject) = "restart") Then
        Call Shell("Shutdown /r")
    End If
    If (LCase(lastItem.Subject) = "lock") Then
        a = LockWorkStation()
    End If
 Next
End Sub
  • Now save the VB Editor and close it and you are done.

How to send Email ?

 
Now you can shutdown/restart/logoff/lock your computer from a remote location by sending a mail. Just send a mail to the email address which you have configured in Outlook. You need to mention either shutdown/logoff/restart/lock in the subject field to do different tasks respectively. The same has been written below.
  •  Write "shutdown" without the quotes in the subject field to shutdown your computer.
  •  Write "logoff" without the quotes in the subject field to logoff your computer.
  •  Write "restart" without the quotes in the subject field to restart your computer.
  •  Write "lock" without the quotes in the subject field to lock your computer.
Example: Suppose the email which you have configured in Outlook is exampl@gmail.com. Then to shutdown your computer from a remote location, just send a mail from any other email ID as following.

TO:example@gmail.com
Subject:shutdown
Body:You can write anything in the body.

You may also like to see