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.
Thread starter Similar threads Forum Replies Date
J Diane's Delay Delivery at Specific Times Questions Outlook VBA and Custom Forms 5
T Query About "Delay Delivery" Function Using Outlook 6
Diane Poremsky Delay Delivery of Messages Sent at Specific Times New Slipstick.com Articles 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
K Outlook 2007 Delay Delivery feature not working Using Outlook 1
P Delay delivery not working in Outlook Using Outlook 1
S Delivery delay set by default 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 Outlook 2007 delay delivery is automatically setting on every email?? 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
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 New Slipstick.com Articles 0
B Macro to delay email Outlook VBA and Custom Forms 0
Diane Poremsky To delay sending a message in Outlook New Slipstick.com Articles 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
L Delay / Send outgoing mail during certain hours Using Outlook 1
N Outlook 2007 and 2010 New Mail Delay Exchange Server Administration 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
B Outlook - Delay in loading messages in Outlook folder Using Outlook 2
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
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
Similar threads


















































Top