Diane's Delay Delivery at Specific Times Questions

jamiers

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

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

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.
 
Thread starter Similar threads 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
J "Outlook cannot display this view" I tried following Diane's suggestions in past posts...but still Using Outlook 1
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 6
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
P Delay delivery not working in Outlook Using Outlook 1
J Delay sending emails in Office Outlook 2010 Using Outlook 2
A E-mail receive delay in Exchange 2010 Exchange Server Administration 4
H Messages won't leave Outbox - sit in Date:None and cannot be sent (delay send becomes checked as wel Using Outlook 1
S Delivery delay set by default Using Outlook 2
B Outlook - Delay in loading messages in Outlook folder Using Outlook 2
H Delay Delivery Option is being automatically selected and cannot be changed and does not allow emails to be sent. Using Outlook 1
I 5 minute delay sending email from 2010 to 2003 Exchange Server Administration 11
L Receiving Mail Delay Using Outlook 10
M Mail delay when sending massive mail throuhg Exchange 2010 Exchange Server Administration 9
C Exchange 2010 email delay Exchange Server Administration 3
N Re: Mail Flow Delay in Exchnage 2010 Exchange Server Administration 1
N Mail Flow Delay in Exchnage 2010 Exchange Server Administration 12
F OUTLOOK 2010 - How to delay sent mail? Using Outlook 2
C Delay Sending Messages option--Outlook 2007 Using Outlook 4
N Outlook 2010, Emails are sent promptly but recipient gets only after long delay (45-60 minutes) Using Outlook 1
K Delay after creating a room before Set-CalendarProcessing functions Exchange Server Administration 8
C Delay the message you send from MS Exchange 2007 Exchange Server Administration 3
I Outlook 2007 delay delivery is automatically setting on every email?? Using Outlook 1
A Re: Outlook 2010 connection to Exchange 2010 Delay Exchange Server Administration 3
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
Similar threads


















































Top