2016-04-03 74 views
1

我試圖將電子郵件轉換爲任務並將該任務放入共享任務文件夾中。我的同事與我分享了該文件夾,但也讓我擁有者可以訪問該文件夾。VBA - Outlook - 在共享任務列表中創建任務

我們已經使用了slipstick上的腳本來完成此操作。此代碼對我的同事有效,但對我無效。

當我深入到可用文件夾列表中時,我只能將我的個人任務列表看作文件夾而不是共享文件夾。 (通過下面的代碼)

有什麼辦法可以將任務添加到共享任務文件夾?

Public strFolders As String 

    Public Sub GetFolderNames() 
     Dim olApp As Outlook.Application 
     Dim olSession As Outlook.NameSpace 
     Dim olStartFolder As Outlook.MAPIFolder 
     Dim lCountOfFound As Long 

     lCountOfFound = 0 

     Set olApp = New Outlook.Application 
     Set olSession = olApp.GetNamespace("MAPI") 

     ' Allow the user to pick the folder in which to start the search. 
     Set olStartFolder = olSession.PickFolder 

     ' Check to make sure user didn't cancel PickFolder dialog. 
     If Not (olStartFolder Is Nothing) Then 
      ' Start the search process. 
      ProcessFolder olStartFolder 
     End If 

    ' Create a new mail message with the folder list inserted 
    Set ListFolders = Application.CreateItem(olMailItem) 
     ListFolders.Body = strFolders 
     ListFolders.Display 

    ' clear the string so you can run it on another folder 
     strFolders = "" 
    End Sub 

    Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder) 

     Dim i As Long 
     Dim olNewFolder As Outlook.MAPIFolder 
     Dim olTempFolder As Outlook.MAPIFolder 
     Dim olTempFolderPath As String 
     ' Loop through the items in the current folder. 
     For i = CurrentFolder.Folders.Count To 1 Step -1 

      Set olTempFolder = CurrentFolder.Folders(i) 

      olTempFolderPath = olTempFolder.FolderPath 

     ' Get the count of items in the folder 
      olCount = olTempFolder.Items.Count 

     'prints the folder path and name in the VB Editor's Immediate window 
      Debug.Print olTempFolderPath & " " & olCount 

      ' prints the folder name only 
      ' Debug.Print olTempFolder 

      ' create a string with the folder names. 
      ' use olTempFolder if you want foldernames only 
      strFolders = strFolders & vbCrLf & olTempFolderPath & " " & olCount 

      lCountOfFound = lCountOfFound + 1 

     Next 
     ' Loop through and search each subfolder of the current folder. 
     For Each olNewFolder In CurrentFolder.Folders 

      'Don't need to process the Deleted Items folder 
      If olNewFolder.Name <> "Deleted Items" Then 
       ProcessFolder olNewFolder 
      End If 

     Next 

    End Sub 

回答

1

此外,任務文件夾,您將需要權限,您的同事的郵箱。 (不是收件箱或其他文件夾。)

如果將郵箱添加到您的配置文件中,請參閱接受的答案here

如果您未將郵箱添加到您的個人資料中,請參閱描述GetSharedDefaultFolder的回答。贖回不是必需的。