2017-06-12 216 views
0

enter image description here如何刪除已刪除項目從Outlook PST文件夾文件

嗨, 我已經創建使用C#代碼PST文件。我的示例代碼在這裏。

string pstlocation = @"C:\Users\{USER}\Desktop\PST Files\Test.pst"; 
Outlook._Application OutlookObject = this.Application; 
Outlook.NameSpace outlookNs = null; 
Outlook.Folder objRootFolder = null; 
outlookNs = Application.GetNamespace("MAPI");  

outlookNs.AddStore(pstlocation); 
objRootFolder = outlookNs.Folders.GetLast() as Folder;  

我的PST文件是Outlook 2013年成功添加,當我試圖刪除已刪除郵件,但它並沒有被刪除,它給了我們一個錯誤。

foreach (Folder objFolder in objRootFolder.Folders) 
    { 
      objFolder.Delete(); 
      //It gives an error. 
    } 

錯誤:「System.Runtime.InteropServices.COMException」類型的異常出現在OutlookAddInPSTTest.dll但在用戶代碼中沒有處理

其他信息:無法刪除此文件夾。用鼠標右鍵單擊該文件夾,然後單擊屬性以檢查該文件夾的權限。查看文件夾所有者或您的管理員以更改您的權限。

============================================== =====================

那麼,我怎樣才能從PST文件中刪除已刪除的項目

回答

0

默認情況下,您不能刪除Outlook使用的特殊文件夾。但是有一些MS Exchange實用程序/客戶端允許它, Outlook將在啓動時重新創建它們。

參考:Microsoft Support- Cannot delete default Outlook folders

  • 收件箱
  • 草稿
  • 發送郵件
  • 已刪除郵件
+0

做着丟失的研究之後, 我能夠知道使用PropertyAccessor接口,我們能夠隱藏此文件夾但無法刪除此默認文件夾。 –

+0

要隱藏此文件夾,我們必須將此http://schemas.microsoft.com/mapi/proptag/0x10F4000B屬性設置爲true。 –

相關問題