【问题标题】:How to set the rules in outlook profile如何在 Outlook 配置文件中设置规则
【发布时间】:2020-06-11 06:11:37
【问题描述】:

我已经从 Store.GetRules 方法 (Outlook) 获得了所有 Outlook 配置文件规则,现在我该如何设置其他配置文件中的所有规则

【问题讨论】:

    标签: c# outlook profile rules


    【解决方案1】:

    您可以使用Rules.Create 方法创建一个Rule 对象,其名称由Name 指定,规则类型由RuleType 指定。

    Sub CreateRule()  
     Dim colRules As Outlook.Rules  
     Dim oRule As Outlook.Rule  
     Dim colRuleActions As Outlook.RuleActions  
     Dim oMoveRuleAction As Outlook.MoveOrCopyRuleAction  
     Dim oFromCondition As Outlook.ToOrFromRuleCondition  
     Dim oExceptSubject As Outlook.TextRuleCondition  
     Dim oInbox As Outlook.Folder  
     Dim oMoveTarget As Outlook.Folder 
    
     'Specify target folder for rule move action  
     Set oInbox = Application.Session.GetDefaultFolder(olFolderInbox)  
     'Assume that target folder already exists  
     Set oMoveTarget = oInbox.Folders("Eugene")  
    
     'Get Rules from Session.DefaultStore object  
     Set colRules = Application.Session.DefaultStore.GetRules()  
    
     'Create the rule by adding a Receive Rule to Rules collection  
     Set oRule = colRules.Create("Eugene's rule", olRuleReceive) 
    
     'Specify the condition in a ToOrFromRuleCondition object  
     'Condition is if the message is sent by "Eugene"  
     Set oFromCondition = oRule.Conditions.From  
     With oFromCondition  
     .Enabled = True  
     .Recipients.Add ("Eugene")  
     .Recipients.ResolveAll  
     End With 
    
     'Specify the action in a MoveOrCopyRuleAction object  
     'Action is to move the message to the target folder  
     Set oMoveRuleAction = oRule.Actions.MoveToFolder  
     With oMoveRuleAction  
     .Enabled = True  
     .Folder = oMoveTarget  
     End With  
    
     'Specify the exception condition for the subject in a TextRuleCondition object  
     'Exception condition is if the subject contains "fun" or "chat"  
     Set oExceptSubject = _  
     oRule.Exceptions.Subject  
     With oExceptSubject  
     .Enabled = True  
     .Text = Array("fun", "chat")  
     End With 
    
      'Update the server and display progress dialog  
      colRules.Save  
    End Sub
    
    

    【讨论】:

    • 我不想创建规则我使用 var session1 = sourceAccInfo.Session; Outlook._Stores 商店 = session1.Stores; var SourceRules = session1.Stores.Application.Session.DefaultStore.GetRules();现在我只是将这个规则复制到其他配置文件中
    猜你喜欢
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-29
    • 2021-01-12
    相关资源
    最近更新 更多