PS script for outgoing email delay


  • Hi Guys

    Looking for a PowerShell script to create an outlook rule for delaying all outgoing emails to x amount of time. I have found one but having errors

    $olFolders = "Microsoft.Office.Interop.Outlook.OlDefaultFolders" -as [type]
    $outlook = New-Object -ComObject outlook.application
    $namespace  = $Outlook.GetNameSpace("mapi")
    $rules = $outlook.session.DefaultStore.GetRules()
    $rule = $rules.Create("1MinDelay",$olRuleType::OlRuleSend)
    $date = Get-Date
    $date = $date.AddMinutes(10)
    $rule.DeferredDeliveryDate = $date
    $rules |
    Sort-Object -Property ExecutionOrder |
    Format-Table -Property Name, ExecutionOrder, Enabled, isLocalRule -AutoSize


    Error Details:

    The property 'DeferredDeliveryDate' cannot be found on this object. Verify that the property exists and can be set.
    At line:8 char:1
    + $olRuleType.DeferredDeliveryDate = $date
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyNotFound

    Any help would be much appreciated.

    Thank you

    • Edited by ChFaisal Monday, March 20, 2017 4:16 AM
    • Moved by Bill_Stewart Friday, April 28, 2017 8:06 PM This is not "research solution for me" forum
    Monday, March 20, 2017 2:28 AM

All replies

  • Please repost your code correctly using the code posting tool.  It cannot be copied correctly.

    $ol = New-Object -ComObject outlook.application
    $namespace = $ol.GetNameSpace('mapi')
    $rules = $ol.Session.DefaultStore.GetRules()
    $rule = $rules.Create('1MinDelay', [Microsoft.Office.Interop.Outlook.OlRuleType]::olRuleSend)
    #$rule.DeferredDeliveryDate = [datetime].Now.AddMinutes(10)
    $rules += $rule
    $rules | 
    	Sort ExecutionOrder |
    	Select Name, ExecutionOrder, Enabled, isLocalRule 

    There is no such property.

    The only thing like it is on a mail item:


    • Edited by jrv Monday, March 20, 2017 3:01 AM
    Monday, March 20, 2017 2:58 AM
  • Hi

    I have copied the script using the utility. Can you suggest any possibility to make this script working?

    Thank you

    • Edited by ChFaisal Monday, March 20, 2017 4:24 AM
    Monday, March 20, 2017 4:14 AM
  • You cannot set a delivery/send delay on a folder of store.  You can only set it on each mail item.   You will need to do this with a VBA project as it cannot be easily or reliably done from PowerShell. 

    Post in Outlook developers forum for help with VBA projects.


    Monday, March 20, 2017 4:26 AM
  • Ok Thank you.
    Monday, March 20, 2017 4:28 AM