for (int i = folder.Items.Count; i > 0; i--)
{
itemsProcessedCount++;
if (itemsProcessedCount%100 == 0)
{
Console.WriteLine("\nNo Of Items Processed: {0}", itemsProcessedCount);
}
var a = folder.Items[i]; // Randomly getting exception here
if (!(a is OutLook._MailItem))
{
continue;
}
var mailItem = a as OutLook._MailItem;
// do the processing and move the item.
mailItem.Move(processedFolder);
}
我正在嘗試使用Microsoft.Office.Interop.Outlook處理來自pst的mailitems;在處理項目時,應用程序在處隨機拋出異常,var a = folder.Items [i];枚舉pst項目時出現錯誤
System.Runtime.InteropServices.COMException發生
的HResult = -2147219437消息=操作失敗。消息傳遞 接口已返回未知錯誤。如果問題仍然存在, 重新啓動Outlook。來源=微軟的Outlook錯誤碼= -2147219437
堆棧跟蹤: 在Microsoft.Office.Interop.Outlook._Items.get_Item(對象索引)
我似乎解決這個問題增加睡眠時間之後。 Thread.Sleep(3000); var a = folder.Items[i]; // Randomly getting exception here
但是同樣的錯誤導致應用程序崩潰。
有沒有人有解決這個問題?迫切需要幫助。 謝謝。
AHHHHH!比賽狀況我得到了你。我正在尋找這個術語。謝謝。 – Sameer
很高興幫助! :) – Baldrick