Outlook defer weekend emails macro - Outlook thinks Sunday is Monday
Hi,
I've been trying to create a Macro to defer weekend emails to the following Monday morning. Once I have a fully working code, I want to roll it out to my wider team so that people have time to relax and think over weekends
I have code that sort of works, but Outlook seems to think that Saturday is Sunday, and Sunday is Monday. A workaround is to simply define the day that seems to work. But I don't know if this is going to work with the rest of the team. Is there any way to fix this?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
' ====================================================================================
' Weekends:
' Do not send emails until Monday morning
' If the email has been flagged as "high importance", then it will still be sent
' ====================================================================================
' Check if it is a Satuday - if so defer email to Monday unless "high importance"
' Note for some stupid reason, My Outlook thinks "Sunday" = Saturday - Why???
If WeekdayName(Weekday(Now())) = "Sunday" Then
' Check if the email is high importance
If Item.Importance = 2 Then
'Do nothing - i.e. let the email be sent
Else
' Delay the email to monday morning 7am
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 2) + #7:00:00 AM#
End If
' Check if it is a saturday - if so defer email to Monday unless "high importance"
' Note for some stupid reason, My Outlook thinks "Monday" = Sunday - Why???
ElseIf WeekdayName(Weekday(Now())) = "Monday" Then
' Check if the email is high importance
If Item.Importance = 2 Then
'Do nothing - i.e. let the email be sent
Else
' Delay the email to monday morning 7am
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #7:00:00 AM#
End If
Item.DeferredDeliveryTime = sendat
End Sub