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.

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

Mike Hudson

Mike Hudson is a Infrastructure Analyst living and working in Kingston Upon Hull. With extensive experience in Microsoft and Apple technologies, ranging from desktop OS’s to Server OS’s and hardware. By day working as part of an infrastructure team, and by night ridding the world of IT issues through blog posts..

  • 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!

    • I shall always expect a delay in your response should I email you in future 😀

  • 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

  • Brian.Lain

    Is there a way to deploy this script to users (ala Group Policy, etc.)?

    • Hi Brian, the ‘best way’ would be to publish this code as an Outlook Add-in

      There’s also one other method you could try (as per: http://www.outlookcode.com/article.aspx?id=28)

      “All Outlook macros are stored in a single file named VbaProject.otm in the user’s %appdata%MicrosoftOutlook folder, which will be a hidden folder on most systems. The brute force approach is to copy this file from the machine where the macros were written to other users’ machines, replacing any existing VbaProject.otm file. You can do this with whatever technique you normally use in your organization to copy files to users, including walking it around on a disk to each workstation.

      This method has the advantage of being a relatively simple process of copying a single file, once you figure out the destination folder. (TIP: You can enter %appdata%MicrosoftOutlook in Start | Run or the Address box in Windows Explorer to go directly to the right folder.)

      Disadvantages include:

      Any Outlook VBA code the user already has will be lost.

      In Outlook 2000 and 2002, at least, the user will need to use Alt+F8 or Alt+F11 manually before any Application-level event code will fire.”

      You may be able to override the code level restrictions in the same GPO.

      I don’t have it as a Add-in currently, but could look at doing it if you get stuck.

      Cheers
      Mike

      • Brian.Lain

        If we were to go the Add-in route, could it be packaged in either MSI or EXE installer format to be deployed that way?

        • Hi Brian

          Yes, if it was a published add-in using visual studio, with the Microsoft Office tools, you could easily package this as an MSI and deploy.

          Thanks
          Mike

          • Brian.Lain

            Ok, so I’ve tried to create an add-in with Visual Studio 2015 Express (the free “Community” version) and it’s not quite working right. The VB works in OTM, but not in the clickonce add-in. Plus the free version of VS2015 doesn’t allow publishing as redistribute-able MSI or EXE.

            Could you please create an MSI installer based add-in for Outlook 2013 that has a send delay of 10 minutes, with an exception for messages marked as High Importance? Sadly, my noob programming skills do not appear up to the task.

          • Hi Brian

            I can, alas it may have to wait till I come back from holiday. So will be in around 2 weeks time.

            I’ll reply to the comment thread with a link once done.

            Cheers
            Mike

          • Brian.Lain

            Alright, scratch that then (thanks anyway). I’ve successfully deployed the OTM file to a test machine, so I might just go that route (of course management wants this done ASAP). So one last questions would be: how can I code in the “High Importance” exception?

          • Isn’t that always the way 🙂

            Ok. Again – without a computer it’s not overly easy to type out/test.

            The outlook mail item object has a property named importance

            So something along the lines of:

            If objMailItem.importance olimportance.olImportanceHigh Then

            At the top of the sub (underneath on error go to…)

            Then
            End If just above the error handler should do the trick.

            Again – I’m composing from my iPhone, so testing isn’t an option for me currently. Hopefully will get you on the right track though.

            Cheers
            Mike

          • Brian.Lain

            Mike, long time no bug. So, we’re revisiting the add-in idea, as deploying via OTM is a bit of a bear (done it twice now for ~40 users). Is there a way to get the add-in to look to a config file of some sort (divorcing the timings from the code)?

          • Hi Brian

            I did think it may be an annoying challenge. There’s a couple of ways you could do that, maybe look at storing the settings in the registry? That way you could look at controlling via policy if required?

%d bloggers like this: