Reputation: 21
I am trying to get the time to change to 9am. It hasn't worked or has removed the preceding DateAdd("d", 2, now) which assigns it for 2 days time.
replyEmail.DeferredDeliveryTime = DateAdd("d", 2, Now)
I tried different DateTime functions, defining certain values, e.g. Date + Time("09:00:00")
Upvotes: 0
Views: 391
Reputation: 9179
Option Explicit
Sub deferredDelivery_2D9H()
Dim mItem As MailItem
Dim d2_9AM As Date
Debug.Print "Date + 2 time format......: " & Format(Date + 2, "ddddd hh:nn")
d2_9AM = DateAdd("h", 9, Date + 2)
Debug.Print "d2_9AM....................: " & d2_9AM
Set mItem = CreateItem(olMailItem)
mItem.DeferredDeliveryTime = d2_9AM
Debug.Print "mItem.DeferredDeliveryTime: " & mItem.DeferredDeliveryTime
mItem.Display
' "Do not deliver before" entry in Options Tracking Properties dialog
'ActiveInspector.CommandBars.ExecuteMso ("DelayDeliveryOutlook")
' Options Tracking Properties dialog
ActiveInspector.CommandBars.ExecuteMso ("MessageOptions")
End Sub
Upvotes: 0
Reputation: 21
After playing around for two days, it appears I've stumbled upon my answer.
replyEmail.DeferredDeliveryTime = DateAdd("d", 2, Date) + DateAdd("n", 0, #9:00:00 AM#)
My issue was finding the right object and then how to join the two so the function didn't override itself causing only the date or time to be correct, but not both.
I'm sure there is a way to make this look cleaner and if I discover it, I'll post but this does the job for the time being.
Upvotes: 2