2016-03-04 62 views
3

我正在使用Outlook 2013,並試圖找出如何創建一個腳本來自動化在特定時間範圍內啓用OoO助理的過程。如何設置具有特定時間範圍的自動離開辦公室回覆

到目前爲止,我已經在下面創建了腳本(可以看到相應的功能),它可以成功更改文本並啓用OoO助理,但我無法找到是否可以設置特定的時間範圍。

Private Function Set_OoO(Subs As String, M As String, oStores As Outlook.Stores, oStr As Outlook.Store, oPrp As Outlook.PropertyAccessor) 

Dim oStorageItem As Outlook.StorageItem 
Set oStorageItem = Application.Session.GetDefaultFolder(olFolderInbox).GetStorage("IPM.Note.Rules.O ofTemplate.Microsoft", olIdentifyByMessageClass) 

oStorageItem.Body = "I am out of the office, please talk to " + Subs 
oStorageItem.Save 

For Each oStr In oStores 
    If oStr.ExchangeStoreType = olPrimaryExchangeMailbox Then 

    Set oPrp = oStr.PropertyAccessor 
    Call oPrp.SetProperty(M, True) 
    End If 
Next 
Set olkIS = Nothing 
Set olkPA = Nothing 

End Function 
+0

檢查了這一點... https://stackoverflow.com/questions/12257985/outlook-vba-run- a-code-every-half-a-hour#15207463 ... – jsotola

回答

0

OOF時間範圍只能通過EWS進行設置,即使用UserOofSettings動詞。它不能使用Outlook對象模型或擴展MAPI進行設置。

如果使用Redemption是一個選項,它將公開RDOOutOfOfficeAssistant對象。由於它執行EWS呼叫,它將需要郵箱用戶的憑據。

 set Session = CreateObject("Redemption.RDOSession") 
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT 
    Session.Credentials.Add "*.myserver.com", "Domain\UserName", "MyPassword" 
    set OofAssistant = Session.Stores.DefaultStore.OutOfOfficeAssistant 
    OofAssistant.BeginUpdate 
    OofAssistant.StartTime = #12/21/2011# 
    OofAssistant.EndTime = #01/03/2012 9:00# 
    OofAssistant.State = 2 'rdoOofScheduled 
    OofAssistant.ExternalAudience = 1 'rdoOofAudienceKnown 
    OofAssistant.OutOfOfficeTextInternal = "<html><body>I am on vacation from 12/21/2001 until 01/03/2012. Please contact " & _ 
      "<a href=""mailto:[email protected]"">Joe User</a>" & _ 
      " if you have any questions</body></html>" 
    OofAssistant.OutOfOfficeTextExternal = "<html><body>I am on <b>vacation</b> until next year. </body></html>" 
    OofAssistant.EndUpdate 
0

您可以設置每日循環任務/約會,提醒和唯一主題。

在ThisOutlookSession模塊

Option Explicit 

Private Sub Application_Reminder(ByVal Item As Object) 

    If Item.MessageClass = "IPM.Task" Then 

     If Item.Subject = "Start OoO" Then 
      ' call code to start OoO 
     ElseIf Item.Subject = "Stop OoO" Then 
      ' call code to stop OoO 
     End If 

    End If 

End Sub 

你還可駁回提醒Dismiss Outlook reminder

相關問題