Trigger Outlook VBA when Windows is locked

283 Views Asked by At

I use VBA code (got online) for sending emails through Outlook when a reminder is triggered. It fails to trigger when Windows is locked. Is there a way to call this (maybe using VBScript or batch) when Windows is locked?

This is the code from "http://www.slipstick.com/developer/send-email-outlook-reminders-fires/"

Private Sub Application_Reminder(ByVal Item As Object)
    Dim objMsg As MailItem
    Set objMsg = Application.CreateItem(olMailItem)
    If Item.MessageClass <> "IPM.Appointment" Then
        Exit Sub
    End If
    If Item.Categories <> "Away Time Alert" Then
        Exit Sub
    End If
    objMsg.To = Item.Location
    objMsg.Subject = Item.Subject
    objMsg.Body = Item.Body
    objMsg.Send
    Set objMsg = Nothing
End Sub

I have no knowledge of this programming.

Ultimate aim -

I want task scheduler to run a script when it has been more than 60 minutes of Windows being locked (logged in and then locked) which will run an Outlook macro to send me an email (when windows is still locked).

1

There are 1 best solutions below

0
On

When windows is locked, outlook can't authenticate. Try the CDO Message with authentication against remote server instead. You will have to know the port of the SMTP server you use.

http://www.paulsadowski.com/wsh/cdo.htm