Can anyone help me figure out why it's grabbing the "To" name not the "To" email address"?
Public 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 **********"
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
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
Dont worry about the timing that i have fixed but the rest....
I need this done by yesterday so if any one can help me
I tried using
If Len(msg) > 0 Then
Set newReply = newMail.Reply
CreateMail newReply.Recipients(0), 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
.Recipients.Add (ReplyAddress)
.Body = msg
.Subject = "Please Note!"
.Display
' or
' .Send
End With
End Sub
But that did nothing.
Thanks