Diane's Delay Delivery at Specific Times Questions

jamiers

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I have just implemented Diane's Delay Delivery of Messages Sent at Specific Times VBA script -- Delay Delivery of Messages Sent at Specific Times. It seems to be working. Now... I have two questions around this:
1. What happens if I want to send an emergency email immediately? Is there a quick button attached to a script that I could click instead of clicking the Outlook Send Button. What would that script be?

2. Is there a way to implement a holiday schedule? I'm experiencing this right now. My boss said NO EMAILS on Weekends or Holidays unless it was an emergency. I want to put in a calendar of "holidays" into the script to check if it is a holiday. This could be done yearly -- I don't care if it does. How would I do that?
 

jamiers

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
I just tried to edit this entry above, but it is past the 3 minute time frame... I am using this code:


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim dayname As String

' If after 6PM
If Now() > DateSerial(Year(Now), Month(Now), Day(Now)) + #5:59:00 PM# Then
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #8:00:00 AM#
' If before 8AM
ElseIf Now() < DateSerial(Year(Now), Month(Now), Day(Now)) + #7:59:00 AM# Then
sendat = DateSerial(Year(Now), Month(Now), Day(Now)) + #8:00:00 AM#
' We'll test the date of all messages
ElseIf WeekdayName(Weekday(Now())) = "Saturday" Or WeekdayName(Weekday(Now())) = "Sunday" Then
' this will be changed by the next part if a weekend
sendat = DateSerial(Year(Now), Month(Now), Day(Now)) + #11:00:00 PM#
End If

dayname = WeekdayName(Weekday(sendat))

Select Case dayname
Case "Saturday"
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 2) + #8:00:00 AM#
Case "Sunday"
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #8:00:00 AM#
End Select
Item.DeferredDeliveryTime = sendat
Debug.Print Now(), dayname, sendat

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
1. What happens if I want to send an emergency email immediately? Is there a quick button attached to a script that I could click instead of clicking the Outlook Send Button. What would that script be?

2. Is there a way to implement a holiday schedule? I'm experiencing this right now. My boss said NO EMAILS on Weekends or Holidays unless it was an emergency. I want to put in a calendar of "holidays" into the script to check if it is a holiday. This could be done yearly -- I don't care if it does. How would I do that?
1. You need to add an If statement to check for a category, flag, importance, or keyword in the subject to bypass the hold. The macro can remove the value as part of the check.

This is the category method (code goes first - right after the DIM:
If Item.Categories = "Send Now" Then
Item.Categories = ""
Exit Sub
End if


2. I have a GetHolidays macro that checks the calendar for holidays. It would need implemented into the macro. I'll look it over and see if i can figure it out.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Not tested at all... I assume you want to delay the message an extra day if tomorrow is a holiday? i think this code + the Getholidays macro is a start - try it after the Sat/Sunday checks. I'm not sure if the V and sendat values need formatted - sendat might need to formatted as mm/dd/yy or using dateserial without the time added.

Again, i have not tested this.

Code:
Dim V As Variant 
Holidays = Split(strAllDayOOF, ",")
' test for holidays
For Each V In Holidays
      If V = sendat Then ' check the format for V and sendat and adjust as needed
          ' tomorrow is a holiday
          ' delay the message another day
   sendat = DateSerial(Year(sendat), Month(sendat), Day(sendat) + 1) + #8:00:00 AM#
          Exit For
      End If
Next V

Item.DeferredDeliveryTime = sendat
 

jamiers

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
So, I'm running into issues where email that I am sending today (and appointment replies/forwards) are still holding in my outbox two days in advance. So, I must have something wrong here...

Code:
'Categorize Sent Items
'Place in ThisOutlookSession
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If TypeOf Item Is Outlook.MailItem And Len(Item.Categories) = 0 Then
        Set Item = Application.ActiveInspector.CurrentItem
        Item.ShowCategoriesDialog
    End If
    
    
    
    Dim dayname As String

If Item.Categories = "Send Now" Then
Item.Categories = ""
Exit Sub
End If

' If after 6PM
If Now() > DateSerial(Year(Now), Month(Now), Day(Now)) + #5:59:00 PM# Then
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #8:00:00 AM#
' If before 8AM
ElseIf Now() < DateSerial(Year(Now), Month(Now), Day(Now)) + #5:59:00 AM# Then
sendat = DateSerial(Year(Now), Month(Now), Day(Now)) + #8:00:00 AM#
' We'll test the date of all messages
ElseIf WeekdayName(Weekday(Now())) = "Saturday" Or WeekdayName(Weekday(Now())) = "Sunday" Then
' this will be changed by the next part if a weekend
sendat = DateSerial(Year(Now), Month(Now), Day(Now)) + #11:00:00 PM#
End If

dayname = WeekdayName(Weekday(sendat))

Select Case dayname
Case "Saturday"
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 2) + #8:00:00 AM#
Case "Sunday"
sendat = DateSerial(Year(Now), Month(Now), Day(Now) + 1) + #8:00:00 AM#
End Select
Item.DeferredDeliveryTime = sendat
Debug.Print Now(), dayname, sendat

End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
It's working find here - at least the best I can test it today - they are scheduled for 8AM tomorrow.
 

jamiers

New Member
Outlook version
Outlook 2016 64 bit
Email Account
Office 365 Exchange
Good morning everyone. The script above is working fine, but I would like to tweak it a little more. RIght now I use a desktop computer from home and a laptop computer when I am mobile. This script works as designed and pushes the email to the Exchange Outbox. This outbox seems to be a "local" outbox and not one that moves with my mail from my desktop computer to my laptop computer. So, if I delay delivery on the mail at night time on my desktop computer, it will not send until I turn the desktop computer on again -- which could be the next evening.

I would love for the mail to be in an outbox that syncs over my O365 account to my laptop, but that doesn't seem to be how Outlook is deisgned.

Is there a solution out there that would create a (let's say) "Pending to Send" folder that would sync across my desktop and laptop computer and then when I turn on my laptop computer the next work day it would process the "Pending to Send" folder.

Basically -- Mail goes to the "Pending to Send" folder. Once there, if it is a "send now" it goes to the Outbox immediately. If not, it sits there until the time the delayed delivery comes and then sends it to the outbox? Does this make sense?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Macros could do that - or save a draft and use a macro to look for drafts to send.
The macro could be tweaked to watch another folder

Do you have a business account or outlook.com? If you work online (only possible with business accounts), the mail is stored on the server and will send at the appointed time.
 
Similar threads
Thread starter Title Forum Replies Date
CWM030 A quick question for Diane about Exchange Exchange Server Administration 2
Jeff Rott Diane Question on "Use in a Run a Script Rule" Outlook VBA and Custom Forms 1
P Automatically 'Reply to all', and Change the Subject of Email - Diane P help! Using Outlook 0
J Halp Diane!- Notes Using Outlook 3
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
D Delay Send not working Using Outlook 3
T Query About "Delay Delivery" Function Using Outlook 5
X Delay sending an email until the next working day (public holidays) Outlook VBA and Custom Forms 0
S Delay Delivery Macro Outlook VBA and Custom Forms 1
Diane Poremsky Delay Delivery of Messages Sent at Specific Times New Slipstick.com Articles 0
Diane Poremsky To delay sending a message in Outlook New Slipstick.com Articles 0
B Macro to delay email Outlook VBA and Custom Forms 0
G "Delay Delivery" Email fails to send if opened while in Outbox Using Outlook 4
Diane Poremsky To delay sending a message in Outlook New Slipstick.com Articles 1
D Delay Delivery: Visible to recipients? Using Outlook 1
Y All emails are received with delay on outlook 2010 Using Outlook 5
M How to forward a message and delay sending for up to 30 days Using Outlook 8
R Long delay for outgoing mail Using Outlook 2
P time delay between accessing Outlook file folders, up 20+ second delay Using Outlook 1
W Attachment delay issue for listing network files Using Outlook 1
I Long delay in switching folders since I installed IE 9 Beta Using Outlook 2
S 6 to 8 second delay in folders opening since installing a number of updates yesterday. Using Outlook 1
K Outlook 2007 Delay Delivery feature not working Using Outlook 1
L Delay / Send outgoing mail during certain hours Using Outlook 1
N Outlook 2007 and 2010 New Mail Delay Exchange Server Administration 1
K Delay after creating a room before Set-CalendarProcessing functions Exchange Server Administration 8
J Rule to Forward email but delay delivery 10 minutes Outlook VBA and Custom Forms 2
C Outlook 2007 Delay Delivery Problem Using Outlook 10
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
M cannot change delivery folders with IMAP accounts Using Outlook 0
M VBA to remove deferred delivery on a MeetingItem Outlook VBA and Custom Forms 2
M Delivery receipt for MYOB emails Using Outlook 0
M Why delivery receipt size is same than sent email size or even larger? Using Outlook 1
P Mail delivery failed returning message to sender Using Outlook 1
C Defer email delivery - but when force sent using F9 Using Outlook 1
Z Mail delivery location - I think Using Outlook 1
R Difference between delivery receipts and read receipts__ Using Outlook 2
S Delivery Status Notification (Failure) Using Outlook 3
F Mail Delivery Errors sending to any Hotmail account recipients.__ Using Outlook 2
C Exchange 2010 Mail flow Local Delivery Exchange Server Administration 3
I Cannot view delivery reports. Exchange Server Administration 2
D Exchange 2003 to Exchange 2010 mail stuck in Exchange 2003 Local Delivery Queue Exchange Server Administration 10
P How do I send a 'delivery receipt' notice to sender after rejecting it? Using Outlook 2
M Outlook 2007 default delivery location changes - 2 accounts Using Outlook 2
V change the Default email Delivery Location Outlook VBA and Custom Forms 3

Similar threads

Top