locked
Reading Outlook Shared Tasks with Powershell ? RRS feed

  • Question

  • Hello Everyone,

    i got a question about Shared-Tasks in Outlook.

    # Outlook Connection
    $Outlook = New-Object -ComObject Outlook.Application
    ## Listing Folders in Outlook (Shows Email, Calendar, Tasks etc)
     
    ## Using Default 
    $OutlookTasks = $Outlook.session.GetDefaultFolder(13)
    
    # Read Tasks
    $OutlookTasks = $Outlook.session.GetDefaultFolder(13).Items
    $OutlookTasks | ft Subject, Body


    This shows me my own Task.

    Subject Body   
    ------- ----   
    Test    Task

    But i want to access a Shared-Tasks List, which is listed below from "My Tasks".

    It looks like this:

    >My Tasks
    ---Task
    ---To-Do-List

    >Shared Tasks
    ---Tasklist(i_want_to_read)

    Is there a command to go deeper into my Tasks ?

    Tuesday, December 12, 2017 11:28 AM

All replies

  • Just a quick one, I did not test.

    $OutlookTasks = $Outlook.Session.GetDefaultFolder(olFolderTasks).Parent._
    Folders("SharedFolderTasksName").Items

    Check if it will help, good luck! Merry Christmas!!


    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.

    Wednesday, December 13, 2017 7:06 AM
  • Thanks for your advice but it wont work.

    It says that olFolderTasks is no Method Call of GetDefaultFolder. But i read oldFolderTasks and GetDefaultFolders(13) is the same, so i tryed :

    $OutlookTasks = $Outlook.Session.GetDefaultFolder(13).Parent_Folders("CMG Tasklist 2017").Items

    Now it says:
    Method invocation failed because [System.__ComObject] does not contain a method named 'Parent_Folders'.

    :(

    Wednesday, December 13, 2017 10:48 AM
  • Thanks for your advice but it wont work.

    It says that olFolderTasks is no Method Call of GetDefaultFolder. But i read oldFolderTasks and GetDefaultFolders(13) is the same, so i tryed :

    $OutlookTasks = $Outlook.Session.GetDefaultFolder(13).Parent_Folders("CMG Tasklist 2017").Items

    Now it says:
    Method invocation failed because [System.__ComObject] does not contain a method named 'Parent_Folders'.

    :(

    Oops.. the underscore is just to break the lines so the code can be read easily. Useful in very long lines of code.

    Try:

    $OutlookTasks = $Outlook.Session.GetDefaultFolder(13).ParentFolders("CMG Tasklist 2017").Items


    Every second counts..make use of it. Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.


    • Edited by cguan Thursday, December 14, 2017 8:58 AM
    Thursday, December 14, 2017 8:57 AM
  • I thought about this too but, nooo error again.

    Method invocation failed because [System.__ComObject] does not contain a method named 'ParentFolders'.
    At C:\Users\tschetor\Documents\Projekte\Outlook Time Tool\Outlook Connect.ps1:18 char:1
    + $OutlookTasks = $Outlook.Session.GetDefaultFolder(13).ParentFolders(" ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (ParentFolders:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound
     
    
    
    Application        : Microsoft.Office.Interop.Outlook.ApplicationClass
    Class              : olApplication
    Session            : Microsoft.Office.Interop.Outlook.NameSpaceClass
    Parent             : 
    Assistant          : System.__ComObject
    Name               : Outlook
    Version            : 15.0.0.4981
    COMAddIns          : System.__ComObject
    Explorers          : {System.__ComObject}
    Inspectors         : {}
    LanguageSettings   : System.__ComObject
    ProductCode        : {90150000-0011-0000-0000-0000000FF1CE}
    AnswerWizard       : 
    FeatureInstall     : msoFeatureInstallOnDemand
    Reminders          : {}
    DefaultProfileName : Outlook
    IsTrusted          : False
    Assistance         : System.__ComObject
    TimeZones          : {System.__ComObject, System.__ComObject, System.__ComObject, System.__ComObject...}
    PickerDialog       : System.__ComObject

    Thursday, December 14, 2017 11:59 AM
  • To refer to a parent's folders we would do this:

    ..... Parent.Folders['some folder name']

    $ol = New-Object -ComObject Outlook.Application
    $ol.Session.GetDefaultFolder(13).Parent.Folders['Drafts']

    To get items I n the folder:

    $ol.Session.GetDefaultFolder(13).Parent.Folders['Drafts'].Items

    To search for items:

    $ol.Session.GetDefaultFolder(13).Parent.Folders['Drafts'].Items.Find("[subject]='my project'")


    \_(ツ)_/

    Thursday, December 14, 2017 12:22 PM
  • You can also just directly address the folder you need;

    $ol.Session.Folders['msmith@msn.com'].Folders['Shared Tasks'].Items

    The top level folder is found by using the mailbox name.  All top level folders in a mailbox are subfolders of the mailbox folder.

    You can also use the folders path to get it.


    \_(ツ)_/

    Thursday, December 14, 2017 12:33 PM
  • Hi jrv,

    i tryed your options but it wont work. I think there is a missunderstanding hier.
    The thing i want to access is no Folder, its a Task.

    Its not showing up in the list by doing this :

    $OutlookFolders = $Outlook.Session.Folders.Item(1).Folders
    $OutlookFolders | ft FolderPath

    All your access tips are working for Folders but not for SharedTasks.

    Picture:

    https://i.stack.imgur.com/L8yNv.png

    $OutlookDeletedITems = $Outlook.session.GetDefaultFolder(3)
    $outlookOutbox = $Outlook.session.GetDefaultFolder(4)
    $OutlookSentItems = $Outlook.session.GetDefaultFolder(5)
    $OutlookInbox = $Outlook.session.GetDefaultFolder(6)
    $OutlookCalendar = $Outlook.session.GetDefaultFolder(9)
    $OutlookContacts = $Outlook.session.GetDefaultFolder(10)
    $OutlookJournal = $Outlook.session.GetDefaultFolder(11)
    $OutlookNotes = $Outlook.session.GetDefaultFolder(12)
    $OutlookTasks = $Outlook.session.GetDefaultFolder(13)

    ID 13 should work and it show "My Tasks" with items but no shared Tasks.

    I tryed your Command:

    $Outlook.Session.GetDefaultFolder(13).Parent.Folders['FOLDERNAME'].Items

    got back:

    Array index out of bounds.
    At C:\Users\tschetor\Documents\Projekte\Outlook Time Tool\Outlook Connect.ps1:6 char:1
    + $OutlookFolders = $Outlook.Session.Folders.Item(13).Folders
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [], COMException
        + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
     
    The attempted operation failed.  An object could not be found.
    At C:\Users\tschetor\Documents\Projekte\Outlook Time Tool\Outlook Connect.ps1:20 char:1
    + $Outlook.Session.GetDefaultFolder(13).Parent.Folders['FOLDERNAME'].It ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : OperationStopped: (:) [], COMException
        + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

    PS: 'FOLDERNAME' is not the real name but there is a Persons Name involved so dont worry about the 'FOLDERNAME' Variable in Error code, its only to show the error.




    • Edited by Chang85 Thursday, December 14, 2017 1:28 PM
    Thursday, December 14, 2017 1:17 PM
  • To access a task you have to get the tasks folder and get the items.

    What folder are your shared tasks in? That is the first thing you have to answer.

    'FOLDERNAME' must be a folder in the root of the main mailbox. If it is not then you have to find the correct mailbox and the correct folder.  We can't see your screen so we cannot guess at what you are trying to do.


    \_(ツ)_/

    Thursday, December 14, 2017 2:14 PM