Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My boss wants all the messages I send to him after 5pm to be delivered at 8am the next morning. Is there a way I can set this up as a rule in Outlook so that I don't have to change it manually every time?

share|improve this question
1  
So you want to delay you sending the messages or delay him receiving the messages? Maybe he should just take the exchange server off his phone.. –  Raystafarian Jul 26 '13 at 0:11
    
Thanks for the response. He can't take the server off his phone because he gets other emails. It's just that mine are usually not important enough to be addressed until business hours (I work the late shift) –  Andrew Talbot Jul 26 '13 at 15:02
    
So it'd be better to delay the ones you send rather than what he receives. I'd try using the delay delivery options, or maybe create a rule referencing them –  Raystafarian Jul 26 '13 at 15:32
    
Yeah the issue is that it wouldn't be for all the messages, just the ones sent after 5pm. Is there a way to tie it to the clock like that? –  Andrew Talbot Jul 26 '13 at 17:38

2 Answers 2

Okay. So put this in ThisOutlookSession through the developer tab in visual basic

The Private sub will check for your mail items that are to your boss (change the email, I think it might be case-sensitive)

If it is to your boss, it will run the macro that checks the time and delays it. I had some trouble with the send at 8am code, you may need to mess around with that.

Private Sub application_itemsend(ByVal item As Object, cancel As Boolean)
Dim myItem As mailItem
Set myItem = item
If myItem.Class = olMail And myItem.To = "boss@company.net" Then
Call CheckSendTime
End If

End Sub

Public Sub CheckSendTime()
    Dim myobj As Object
    Dim myMail As mailItem
    Dim WkDay As String
    Dim MinNow As Integer
    Dim SendHour As Integer
    Dim SendDate As Date
    Dim SendNow As String

'Set Variables
SendDate = Now()
SendHour = Hour(Now)
MinNow = Minute(Now)
WkDay = Weekday(Now)
SendNow = Y

'Check if after 5PM
If SendHour > 17 Then           'After 5 PM
    SendHour = 34 - SendHour     'Send at 8 am next day
    SendDate = DateAdd("h", SendHour, SendDate)
    SendDate = DateAdd("n", -MinNow, SendDate)
    SendNow = N
End If

'Send the Email
  Set myobj = Application.ActiveInspector.CurrentItem
  If TypeOf myobj Is Outlook.mailItem Then
    Set myMail = myobj
    'Check if we need to delay delivery
    If SendNow = N Then
      myMail.DeferredDeliveryTime = SendDate
      End If
      Else: myMail.Send
    End If

End Sub

Some sourced from here

share|improve this answer

This solution is basically same as proposed by Raystafarian but with simplified logic.

To use:
1. In Outlook open the code editor, Alt+F11.
2. Under Project1 > Microsoft Outlook Objects double click ThisOutlookSession
3. Paste code below into the editor.
4. Modify email address and time range as necessary.
5. Click the Save button and close code editor window.
6. Change Outlook macro security: Click File > Outlook Options > Trust Center. Click Trust Center Settings then Macro Settings and select Notifications for all macros
7. Restart Outlook and click Enable Macros when prompted.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim bossEmail As String
Dim delaySendAt As Date
Dim currentHour As Integer
bossEmail = "boss@company.net"
delaySendAt = (Date + 1) & " 8:01:00 AM"
currentHour = Hour(Now())

' Delay emails sent between 5PM and 8AM
If currentHour >= 17 Or currentHour < 8 Then
    ' where To field contains boss's email address (case insensitive)
    ' but don't delay message sent to boss and other recipients
    If InStr(1, Item.To, bossEmail, vbTextCompare) > 0 _
        And InStr(Item.To, ";") = 0 Then
        Item.DeferredDeliveryTime = delaySendAt
    End If
End If

End Sub

Emails sent that meet specified conditions will go into Outbox folder when 'Send' button is clicked, but won't be delivered until the specified time. In order for messages to be delivered Outlook application must be running at the scheduled delivery time. If you open a message from Outbox you must click 'Send' again or it won't get sent.

share|improve this answer
    
Thank you for that!! Two questions, though. 1) There are some important emails that I do need to send to him after hours; if I open the message and click Send will it still send? 2) Will this still deliver messages sent to a Distribution Group he's part of? –  Andrew Talbot Jul 29 '13 at 16:33
    
1) No, you'll need to define and check for a condition to accomplish this. By adding And Item.Importance < 2 _ just below If InStr(... will allow messages to boss sent with 'High Importance' to always be delivered immediately. Ref 2) Yes. If it's an Exchange distribution list then the email address in To field won't match then bossEmail; if it's a list of Outlook contacts then the InStr(Item.To, ";") = 0 condition will allow messages sent to boss plus other recipients to be sent immediately. –  gm2 Jul 29 '13 at 20:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.