Please note that below code was found online; however when tested, it did not work. Please can you arrange to fix below code or provide an alternative code: Please note that creating a rule and running a script is not available and modification in registry is not possible.
Option Explicit
Private Declare PtrSafe 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
Thanks
