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
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
E Macro to block senders domain Outlook VBA and Custom Forms 1
D VBA Macro to Print and Save email to network location Outlook VBA and Custom Forms 1
N VBA Macro To Save Emails Outlook VBA and Custom Forms 1
N Line to move origEmail to subfolder within a reply macro Outlook VBA and Custom Forms 0
witzker Outlook 2019 Macro to answer a mail with attachments Outlook VBA and Custom Forms 2
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
J Macro to Insert a Calendar Outlook VBA and Custom Forms 8
W Macro to Filter Based on Latest Email Outlook VBA and Custom Forms 6
T Macro to move reply and original message to folder Outlook VBA and Custom Forms 6
D Autosort macro for items in a view Outlook VBA and Custom Forms 2
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
M Replyall macro with template and auto insert receptens Outlook VBA and Custom Forms 1
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 14
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Globalforester ItemAdd Macro - multiple emails Outlook VBA and Custom Forms 3
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3

Similar threads

Top