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 ?
- 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.
You may also like to see
Not working i m using 2016