How to read all Outlook task fields in Access database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Medaron
    New Member
    • May 2010
    • 1

    #1

    How to read all Outlook task fields in Access database.

    I am trying to wite a vba code to read all my outlook task fields in Access database. So far I have following code:
    Code:
    Sub OutlookTasks()
    
    Dim ol As Object
    Dim olns As Object
    Dim objFolder As Object
    Dim objAllTasks As Object
    Dim Task As Object
    ' Set the Application object.
    Set ol = New Outlook.Application
    ' Set the Namespace object.
    Set olns = ol.GetNamespace("MAPI")
    ' Set the default Tasks folder.
    Set objFolder = olns.GetDefaultFolder(olFolderTasks)
    ' Set objAllTasks equal to the collection of all Tasks.
    Set objAllTasks = objFolder.Items
    ' Loop through each Task.
    For Each Task In objAllTasks
    ' Display the Body field for the Task.
    MsgBox "Task: " & Task.Subject & " Last Update: " & Task.Role
    Next
    End Sub
    I am getting a "compile error: user-defined type not defined" error. I am a total amateur in vba, any help would be great!
  • patjones
    Recognized Expert Contributor
    • Jun 2007
    • 931

    #2
    Hi,

    I think you need to set a reference for Access VBA to be able to communicate with Outlook. For instance, in 2007 you go Tools > References... and then scroll down the list and check mark "Microsoft Outlook 12.0 Object Library" and click OK.

    The code should compile after setting the proper reference.

    Pat

    Comment

    • DataAnalyzer
      New Member
      • May 2010
      • 15

      #3
      Can you just attach to the PST file and reference it from a linked table?

      Comment

      Working...