Home » Delay Outlook mail sending

So today I was approached by an internet friend of mine Richard Tubb, he had a bit of a challenge for me. As a keen Ms Outlook user, he wanted to see if there was a way of delaying all emails that he’d composed and hit send on during the weekend to arrive on the next working day.

Of course, Ms Outlook has the built in deferred delivery time function.. However, setting that manually each time could easily become a bind. So that’s where this little Outlook VBA Snippet steps it.

The code checks to see if today is a weekday upon sending the email, and if it is either a Saturday or Sunday, it then finds the date of the next Monday, and sets the deferred send option to that Monday at 7AM. Of course, should Richard be sending mail through the week, Outlook will simply ignore the code. Simple really :)

EDIT: So Richard came back to me with a second request, to delay mail sent on a weekday by 30 minutes, I have now adjusted the code to suit.

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 (http://msdn.microsoft.com/en-us/library/82yfs2zh(v=vs.80).aspx)
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

If you find this code useful, or think you have a better way of doing this, drop me a line in the comments below!

Cheers
Mike

Home » Delay Outlook mail sending


  • Anonymous

    Mike – a *big* thanks for taking the time to help me here, and share the code as you have. Hugely appreciated! This will have a really positive effect on the way I use e-mail!

    • http://www.mikesel.info/ Mike Hudson

      I shall always expect a delay in your response should I email you in future :D

  • Aron Gahagan

    Very helpful, thank you! I often Send too soon, so with a 5 min delay I can avoid the “oh no!” factor when I’ve forgotten something. My only suggested improvement would be:

    If Weekday(Date, vbMonday) > 6 Then strDeferUntil = Date + (8 – Weekday(Date)) & ” 08:00:00″ Else strDeferUntil = DateAdd(“n”, 5, Now)

    Item.DeferredDeliveryTime = strDeferUntil

  • Aron Gahagan

    Very helpful, thank you! I often Send too soon, so with a 5 min delay I can avoid the “oh no!” factor when I’ve forgotten something. My only suggested improvement would be:

    If Weekday(Date, vbMonday) > 6 Then strDeferUntil = Date + (8 – Weekday(Date)) & ” 08:00:00″ Else strDeferUntil = DateAdd(“n”, 5, Now)

    Item.DeferredDeliveryTime = strDeferUntil


Page 1 of 11

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Recent Posts