How can I automatically send an email with delay from an Outlook inbox usign VBA?

后端 未结 1 1882
滥情空心
滥情空心 2021-01-26 03:59

I\'m new in the ways of VBA and I want to create a rule (script) that can automatically forward an email received in my Outlook inbox with a specified delay? Can you please give

1条回答
  •  执笔经年
    2021-01-26 04:26

    Try using DeferredDeliveryTime Property Which sets the time mail is to be delivered.

    Example

    Option Explicit
    Public Sub Example()
        Dim Item As Outlook.MailItem
    
        Set Item = Application.CreateItem(0)
    
        With Item
            .Subject = "test"
            .To = "0m3r"
            .DeferredDeliveryTime = DateAdd("n", 10, Now)
             Debug.Print Item.DeferredDeliveryTime
            .Send
        End With
    
        Set Item = Nothing
    End Sub
    

    DateAdd Function

    DateAdd("n", 10, Now)
    
    +--------+-----------------+
    | Value  |   Explanation   |
    +--------+-----------------+
    | yyyy   | Year            |
    | q      | Quarter         |
    | m      | Month           |
    | y      | Day of the year |
    | d      | Day             |
    | w      | Weekday         |
    | ww     | Week            |
    | h      | Hour            |
    | n      | Minute          |
    | s      | Second          |
    +--------+-----------------+
    

    0 讨论(0)
提交回复
热议问题