VBA/Excel/Access/Word/Outlook/Outlook Table — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:47, 26 мая 2010

Outlook filter table

 
Public Sub PlayWithFilteredTable()
    Dim myTable As Outlook.Table
    Dim colColumns As Outlook.Columns
    Dim oColumn As Outlook.Column
    Dim oFolder As Outlook.Folder
    Dim myMailItem As Outlook.MailItem
    Dim oRow As Outlook.Row
    Dim oProp As Outlook.UserProperty
    Dim aryValues() As Variant
    Dim strEntryID As String
    Dim strFilter As String
    Set oFolder = Application.Session.GetDefaultFolder(olFolderSentMail)
    strFilter = "[Importance] = 2"
    
    Set myTable = oFolder.GetTable(strFilter)
    Set colColumns = myTable.Columns
    colColumns.RemoveAll
    Set oColumn = colColumns.Add("EntryID")
    Set oColumn = colColumns.Add("Importance")
    
    Do While myTable.EndOfTable = False
        Set oRow = myTable.GetNextRow
        aryValues = oRow.GetValues
        If aryValues(1) = OlImportance.olImportanceHigh Then
            strEntryID = aryValues(0)
            Set myMailItem = Application.Session.GetItemFromID(strEntryID)
            Set oProp = myMailItem.UserProperties.Add("VeryImportant", olYesNo)
            oProp.Value = True
            myMailItem.Save
        End If
    Loop
End Sub



Outlook table

 
Public Sub PlayWithTable()
    Dim myTable As Outlook.Table
    Dim colColumns As Outlook.Columns
    Dim oColumn As Outlook.Column
    Dim oFolder As Outlook.Folder
    Dim myMailItem As Outlook.MailItem
    Dim oRow As Outlook.Row
    Dim oProp As Outlook.UserProperty
    Dim aryValues() As Variant
    Dim strEntryID As String
    Set oFolder = Application.Session.GetDefaultFolder(olFolderSentMail)
    Set myTable = oFolder.GetTable "returns all items in folder
    Set colColumns = myTable.Columns
    colColumns.RemoveAll
    Set oColumn = colColumns.Add("EntryID")
    Set oColumn = colColumns.Add("Importance")
    
    Do While myTable.EndOfTable = False
        Set oRow = myTable.GetNextRow
        aryValues = oRow.GetValues
        If aryValues(1) = OlImportance.olImportanceHigh Then
            strEntryID = aryValues(0)
            Set myMailItem = Application.Session.GetItemFromID(strEntryID)
            Set oProp = myMailItem.UserProperties.Add("VeryImportant", olYesNo)
            oProp.Value = True
            myMailItem.Save
        End If
    Loop
End Sub