Consulting

Results 1 to 3 of 3

Thread: Outlook Object model

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Contributor
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    118
    Location

    Outlook Object model

    Does anyone have any info on the Outlook Object model?
    Looking for a way to export rules into a human readable format (at least)?

    TIA

    I have managed to cobble the below together from snippets on the net, but TBH am getting lost. I am not a developer, but a dabbler.

    Sub TestRule()
        Dim olRules As Outlook.rules
        Dim olRule As Outlook.Rule
        Dim iRule As Integer, iAction As Integer, iException As Integer, iRuleAction As Integer
        Set olRules = Application.Session.DefaultStore.GetRules
        'Set olRule = olRules.item("TestRule")
        For iRule = 1 To 1 'olRules.Count 'Each olRule In olRules
            Debug.Print olRules.item(iRule).Name 'TypeName(iRule)
            Debug.Print olRules.item(iRule).Enabled
            Debug.Print olRules.item(iRule).Actions.Count
            For iAction = 1 To olRules.item(iRule).Actions.Count
                 Debug.Print "ActionType: " & olRules.item(iRule).RuleActions.item(iAction)
                 For iRuleAction = 1 To olRules.item(iRule).RuleActions.item(iRuleAction).Count
                     Debug.Print "RuleACtions: " & olRules.item(iRule).RuleActions.item(iRuleAction)
                 Next
             Next
             Debug.Print olRules.item(iRule).Exceptions.Count
             printArray olRules(iRule).Conditions.Body.Text
             printArray olRules(iRule).Conditions.MessageHeader.Text
        Next
        Set olRules = Nothing
        Set olRule = Nothing
    End Sub
    
    Private Sub printArray(ByRef pArr As Variant)
        Dim readString As Variant
        If (IsArray(pArr)) Then
            'check if the passed variable is an array
            For Each readString In pArr
                If TypeName(readString) = "String" Then 'check if the readString is a String variable
                    Debug.Print readString
                End If
            Next
        End If
    End Sub
    Last edited by Aussiebear; 08-30-2024 at 03:58 PM. Reason: Tidy up presentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •