locked
Emails during business hours ONLY. RRS feed

  • Question

  • How do I set my Outlook so that ALL emails, no matter when composed are sent only during business hours?
    Thursday, September 15, 2011 6:24 PM

Answers

  • If someone has developed a Custom Action, you could add this to one of the Outlook Rules.

    If not, you could try this VBA macro.  I have not tested it extensively but it should work, although the mail might get sent a few seconds late if it is composed at just before the end of the business day.

    This macro is event-triggered, and would have to be installed in every instance of Outlook that you are concerned with.  In addition, if you are using POP3 mail, Outlook would have to be running at delivery time, although the mail would get sent when OL is restarted.

    To enter this macro, with OL running, <alt-F11> opens the VB Editor.  In the Project Explorer, expand Microsoft Ooffice Outlook Objects; then double-click on ThisOutlookSession.  Paste the code below into the window that opens.

    You might need to change the BusHrsStart, BusHrsEnd, and the non-Business Weekdays; but that should be obvious in the code how to do that.

    Test to make sure there are no delays when sending during business hours; and also that during non-business hours that the Options for that mail item show it will get sent at the next start of business.

    ==============================
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Const BusHrsStart As Long = 9
        Const BusHrsEnd As Long = 17
        Dim DtTimeToSend As Date
        Dim myMail As MailItem
    Set myMail = Item
    'Is it in Business Hours now?
    Select Case Hour(Time)
        Case Is < BusHrsStart
            DtTimeToSend = Date + TimeSerial(BusHrsStart, 0, 0)
        Case Is > BusHrsEnd
            DtTimeToSend = Date + 1 + TimeSerial(BusHrsStart, 0, 0)
        Case Else
            DtTimeToSend = Date + Time
    End Select

    Select Case Weekday(DtTimeToSend)
        Case Is = vbSaturday, vbSunday
            DtTimeToSend = DtTimeToSend + 7 - Weekday(DtTimeToSend - 2)
    End Select

    myMail.DeferredDeliveryTime = DtTimeToSend

    End Sub
    ====================================


    Ron
    • Proposed as answer by danishani Wednesday, February 1, 2012 6:19 AM
    • Marked as answer by danishani Tuesday, February 7, 2012 8:02 PM
    Friday, September 16, 2011 2:37 PM

All replies

  • Don't "Send" the email. Save the emails composed outside of business hours in your drafts folder, and send them during business hours.
    HTH, Bernie
    Friday, September 16, 2011 12:59 PM
  • If someone has developed a Custom Action, you could add this to one of the Outlook Rules.

    If not, you could try this VBA macro.  I have not tested it extensively but it should work, although the mail might get sent a few seconds late if it is composed at just before the end of the business day.

    This macro is event-triggered, and would have to be installed in every instance of Outlook that you are concerned with.  In addition, if you are using POP3 mail, Outlook would have to be running at delivery time, although the mail would get sent when OL is restarted.

    To enter this macro, with OL running, <alt-F11> opens the VB Editor.  In the Project Explorer, expand Microsoft Ooffice Outlook Objects; then double-click on ThisOutlookSession.  Paste the code below into the window that opens.

    You might need to change the BusHrsStart, BusHrsEnd, and the non-Business Weekdays; but that should be obvious in the code how to do that.

    Test to make sure there are no delays when sending during business hours; and also that during non-business hours that the Options for that mail item show it will get sent at the next start of business.

    ==============================
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Const BusHrsStart As Long = 9
        Const BusHrsEnd As Long = 17
        Dim DtTimeToSend As Date
        Dim myMail As MailItem
    Set myMail = Item
    'Is it in Business Hours now?
    Select Case Hour(Time)
        Case Is < BusHrsStart
            DtTimeToSend = Date + TimeSerial(BusHrsStart, 0, 0)
        Case Is > BusHrsEnd
            DtTimeToSend = Date + 1 + TimeSerial(BusHrsStart, 0, 0)
        Case Else
            DtTimeToSend = Date + Time
    End Select

    Select Case Weekday(DtTimeToSend)
        Case Is = vbSaturday, vbSunday
            DtTimeToSend = DtTimeToSend + 7 - Weekday(DtTimeToSend - 2)
    End Select

    myMail.DeferredDeliveryTime = DtTimeToSend

    End Sub
    ====================================


    Ron
    • Proposed as answer by danishani Wednesday, February 1, 2012 6:19 AM
    • Marked as answer by danishani Tuesday, February 7, 2012 8:02 PM
    Friday, September 16, 2011 2:37 PM
  • Ron: thank you for the very comprehensive answer.  Regrettably, I have no idea how to implement your suggestion, but I do appreciate your thoughtfulness.

    Sheldon

     

    Saturday, September 17, 2011 10:34 PM
  • Instructions for implementing this are in the response I provided in what I thought were step-by-step instructions.  I don't know how to make it any clearer.  Perhaps there is someone you know who can read what I wrote, and explain it to you.  Or, you can post back outlining the instructions for implementation I provided that you do not understand.
    Ron
    Saturday, September 17, 2011 11:25 PM