I am trying to wite a vba code to read all my outlook task fields in Access database. So far I have following code:
I am getting a "compile error: user-defined type not defined" error. I am a total amateur in vba, any help would be great!
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
Comment