Microsoft Outlook and Exchange

From Kb

Jump to: navigation, search

Contact Article Author | Blog of Article Author | FirstPartners.net Home | LinkedIn profile of Author

Using VBA to get tasks from Outlook

Sub GetTask()
 
    Dim olApp As Outlook.Application
    Dim olNs As Namespace
    Dim Fldr As MAPIFolder
    Dim olTsk As TaskItem
    Dim i As Long
 
    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderTasks)
    i = 1
 
    For Each olTsk In Fldr.Items
        If olTsk.DueDate = #6/26/2003# Then
            ActiveSheet.Cells(i, 1).Value = olTsk.Subject
            i = i + 1
        End If
    Next olTsk
 
    Set olTsk = Nothing
    Set Fldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing
 
End Sub
Personal tools