The code below saves the item in the task folder from outlook but it's just a message and not a task! Do anyone know what's wrong with this code?
Public Function fctnOutlookTask()
Dim objTask As MAPI.Message 'All item types are called Messages in CDO
Dim objTasks As MAPI.Messages
Dim objSession As MAPI.Session
Dim objFolder As MAPI.Folder
Dim strProfile As String, objFields
Set objSession = CreateObject("MAPI.Session")
strProfile = "<server>" & vbLf & "<account"
objSession.Logon , , , False, , True, strProfile
'Get the tasks folder
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderTasks)
'Get the task items collection
Set objTasks = objFolder.Messages
'Can use the Add method here to add a new task
Set objTask = objTasks.Add
Set objFields = objTask.Fields
objFields.Add CdoPR_BODY, "taak 1"
strLContact = "Gerard Krijgsman" 'Assign Contact Name.
objFields.Add CdoTask_Contacts, 8, Trim(strLContact), CdoPropSetID4
objFields.Add CdoTask_DueDate, 8, #7/5/2004#, CdoPropSetID2
objFields.Add CdoTask_PercentComplete, 8, 0, CdoPropSetID2
objTask.Subject = "Dit is een taak"
objTask.Update
Set objTask = Nothing
Set objTasks = Nothing
Set objFolder = Nothing
Set objSession = Nothing
End Function
The DueDate also doesn't work.
Many thanx in advance
Gerard
Public Function fctnOutlookTask()
Dim objTask As MAPI.Message 'All item types are called Messages in CDO
Dim objTasks As MAPI.Messages
Dim objSession As MAPI.Session
Dim objFolder As MAPI.Folder
Dim strProfile As String, objFields
Set objSession = CreateObject("MAPI.Session")
strProfile = "<server>" & vbLf & "<account"
objSession.Logon , , , False, , True, strProfile
'Get the tasks folder
Set objFolder = objSession.GetDefaultFolder(CdoDefaultFolderTasks)
'Get the task items collection
Set objTasks = objFolder.Messages
'Can use the Add method here to add a new task
Set objTask = objTasks.Add
Set objFields = objTask.Fields
objFields.Add CdoPR_BODY, "taak 1"
strLContact = "Gerard Krijgsman" 'Assign Contact Name.
objFields.Add CdoTask_Contacts, 8, Trim(strLContact), CdoPropSetID4
objFields.Add CdoTask_DueDate, 8, #7/5/2004#, CdoPropSetID2
objFields.Add CdoTask_PercentComplete, 8, 0, CdoPropSetID2
objTask.Subject = "Dit is een taak"
objTask.Update
Set objTask = Nothing
Set objTasks = Nothing
Set objFolder = Nothing
Set objSession = Nothing
End Function
The DueDate also doesn't work.
Many thanx in advance
Gerard