OOM & VBA : How to delete Outlook recurring Task items (whose status marked as Completed)


'[VBA & Outlook Object Model : Code snippet to delete Outlook recurring Task items (whose status marked as Completed)]
 
'Declaration part
...
dim otaskitem as Outlook.Taskitem
dim ofolder as Outlook.Folder
 
'Get the Task items
set ofolder = Application.Session.GetDefaultFolder(olFolderTasks)
For each item in ofolder.items
set otaskitem = Item
 
'Check the status of the specific Taskitem is "Completed" or not
if otaskitem.Status = olTaskcomplete then
'Msgbox "Completed Tasks"
otaskitem.Delete
else
'Msgbox "Not Completed Tasks"
end if
Next
....
Comments (2)
  1. deva says:

    I need to squeeze the code in a good looking & working too… Done the changes

    For each item in ofolder.items

    set otaskitem = Item

    ‘Check the status of the specific Taskitem is "Completed" or not

    if otaskitem.Status = olTaskcomplete then

    ‘Msgbox "Completed Tasks"

    otaskitem.Delete

    ‘else

    ‘Msgbox "Not Completed Tasks"

    end if

    Next

    ‘Finally don’t forget to release the objects

Comments are closed.