-1

My PC is always on, and Outlook is always open. I want to write a macro that replies to any sender if a mail is received outside of working hours, every day.

The out of office auto reply's date and time range is too limited for this.

Can anyone assist?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
opperman.eric
  • 314
  • 1
  • 14

1 Answers1

1

How about the following...

Option Explicit
Public Sub Example(Item As Outlook.MailItem)
    If Now() > DateSerial(Year(Now), Month(Now), Day(Now) _
            ) + #5:00:00 PM# _
        Or Now() < DateSerial(Year(Now), Month(Now), Day(Now) _
            ) + #7:00:00 AM# Then

        ' your code here

    End If
End Sub

See here Outlook Reply or ReplyAll to an Email

0m3r
  • 12,286
  • 15
  • 35
  • 71