-
-
Save yakov116/3d3a55792f23c1cc5bc1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enter file contents herePublic Sub Check_ReceivedTime(newMail As Outlook.MailItem) | |
Dim obj As Object | |
Dim ReceivedHour As Integer | |
Dim newReply As MailItem | |
Dim msg As String | |
ReceivedHour = Hour(newMail.ReceivedTime) | |
'Only do anything if before Shabbos | |
If weekday(newMail.ReceivedTime) < 6 Then | |
If weekday(newMail.ReceivedTime) = 5 Then | |
msg = "Sorry I am not in the office, I will respond on Sunday morning. If its urgent please email yitzchok@tntexperts.com" | |
Else | |
If ReceivedHour <= 2 Or ReceivedHour >= 19 Then | |
msg = "Sorry I have have left the office alrady, I will respond tomorrow morning after 10:30 am." | |
ElseIf ReceivedHour >= 3 And ReceivedHour <= 1030 Then | |
msg = "Sorry I am not in the office, I will respond after 10:30 am or on Sunday after 11:am." | |
Else | |
Debug.Print "After 10:30, not Friday. Do not sent the automated reply." | |
End If | |
End If | |
End If | |
'End If | |
If Len(msg) > 0 Then | |
Set newReply = newMail.Reply | |
CreateMail newReply.To, msg | |
MsgBox(newReply.Recipients.Count & " " & newReply.Recipients(0) | |
End If | |
Set newReply = Nothing | |
End Sub | |
Private Sub CreateMail(ReplyAddress As String, msg As String) | |
Dim objMail As Outlook.MailItem | |
Set objMail = CreateItem(olMailItem) | |
With objMail | |
.To = ReplyAddress | |
.Body = msg | |
.Subject = "Please Note!" | |
.Display | |
' or | |
' .Send | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't seem to edit the code, but here is my addition/edition: