Delay Delivery Macro

Status
Not open for further replies.

Steve Wood

New Member
Outlook version
Outlook 2016 64 bit
Email Account
IMAP
Hello All -
I found the below code online that delays delivery to the next business day automatically if sent at night or over the weekend. It is just what I was looking for as I send a lot of business mail in the evenings and weekends and I don't want the mail to interrupt my coworkers off-time. The only problem is that, sometime I do want an email to go out immediately and it doesn't seem like there is an easy way to override the macro. I would love this if when I sent a email after hours a simple pop-up window opened and asked if I wanted to delay delivery. I don't want it any more complex than I could answer with one simple key stroke. ENTER to send on the next business day. I'm not a programmer and know just enough to copy and paste the code into the VBA window. I would be very grateful if someone could tell how to change the code to add this feature. Thanks in advance for any assistance you con provide! Regards...Steve



Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
On Error GoTo ErrHand 'Error Handling
Dim nxtMonday As String 'Variable containing next Monday's date
Dim objMailItem As MailItem 'Object to hold mail item

Set objMailItem = Item 'Set object to mail item just sent


If Weekday(Date, vbMonday) = 6 Then 'Check to see if todays weekday value is 6 (Weekday Function (Visual Basic)
1: nxtMonday = Date + (2) 'As today is saturday, Monday is today + 2 days
2: objMailItem.DeferredDeliveryTime = nxtMonday & " 08:00:00" 'Set delayed delivery time to today + 2 days
Else
3: objMailItem.DeferredDeliveryTime = DateAdd("n", 30, Now) 'Else delay is + 30 minutes
End If

If Weekday(Date, vbMonday) = 7 Then 'Check to see if todays weekday value is 7
4: nxtMonday = Date + (1) 'As today is Sunday, Monday is today + 1 day
5: objMailItem.DeferredDeliveryTime = nxtMonday & " 08:00:00" 'Set delayed delivery time to today + 1 day
Else
6: objMailItem.DeferredDeliveryTime = DateAdd("n", 30, Now) 'Else delay is + 30 minutes
End If

Exit Sub

ErrHand: 'Due to lack of concentration of the code writing genius there has been a bit of an error,
'Lets tell someone about it by popping up a message box with a detailed description on the screen
MsgBox ("An error has occured on line " & Erl & ", with a description: " & Err.Description & ", and an error number " & _
Err.Number)
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J Diane's Delay Delivery at Specific Times Questions Outlook VBA and Custom Forms 7
T Query About "Delay Delivery" Function Using Outlook 5
Diane Poremsky Delay Delivery of Messages Sent at Specific Times Using Outlook 0
G "Delay Delivery" Email fails to send if opened while in Outbox Using Outlook 4
D Delay Delivery: Visible to recipients? Using Outlook 1
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
T Exchange Server - Mail Delay Stamping Exchange Server Administration 0
R Outlook 365 VBA AUTO SEND WITH DELAY FOR EACH EMAIL Outlook VBA and Custom Forms 0
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
K Delay Send and Mail Merge Outlook VBA and Custom Forms 4
D Delay Send not working Using Outlook 3
X Delay sending an email until the next working day (public holidays) Outlook VBA and Custom Forms 0
Diane Poremsky To delay sending a message in Outlook Using Outlook 0
B Macro to delay email Outlook VBA and Custom Forms 0
Diane Poremsky To delay sending a message in Outlook 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
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
V change the Default email Delivery Location Outlook VBA and Custom Forms 3
X Custom icon (not from Office 365) for a macro in Outlook Outlook VBA and Custom Forms 1
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
mrrobski68 Issue with Find messages in a conversation macro Outlook VBA and Custom Forms 1
G Creating Macro to scrape emails from calendar invite body Outlook VBA and Custom Forms 6
M Use Macro to change account settings Outlook VBA and Custom Forms 0
J Macro to Reply to Emails w/ Template Outlook VBA and Custom Forms 3
C Outlook - Macro to block senders domain - Macro Fix Outlook VBA and Custom Forms 1
Witzker Outlook 2019 Macro to seach in all contact Folders for marked Email Adress Outlook VBA and Custom Forms 1
S macro error 4605 Outlook VBA and Custom Forms 0
A Macro Mail Alert Using Outlook 4
J Outlook 365 Outlook Macro to Sort emails by column "Received" to view the latest email received Outlook VBA and Custom Forms 0
J Macro to send email as alias Outlook VBA and Custom Forms 0
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 6
D Outlook 2016 Creating an outlook Macro to select and approve Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to send an Email Template from User Defined Contact Form Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro to check Cursor & Focus position Outlook VBA and Custom Forms 8
V Macro to mark email with a Category Outlook VBA and Custom Forms 4
M Outlook 2019 Macro not working Outlook VBA and Custom Forms 0
S Outlook 365 Help me create a Macro to make some received emails into tasks? Outlook VBA and Custom Forms 1
Geldner Send / Receive a particular group via macro or single keypress Using Outlook 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 21

Similar threads

Back
Top