2016-07-28 10 views
0

プログラムで再帰項目を変更しようとしています(例外を作成しています)。Outlookアドインで例外を保存します。

プロジェクトはOutlook 2010 AddInです。

コードを、私は次のコードを試してみましたが、のカップルがセーブした後は、calitm.Save()コマンドで

extracted ="somelocation" 

//that's a fancy way to iterate on a list of appointment items 
for (int i = 0; i < filterAppointmentsToChangeLocation.RecordCount; i++) 
{ 
    int selrow = 1 
    var calitm = filterAppointmentsToChangeLocation.data[selrow].GetOlAppointment(); 
    //this returns an appointmentitem that is associated with a form 
    //that contains the location property 

    calitm.UserProperties["location"].Value = extracted; 
    calitm.Save(); 

    Marshal.ReleaseComObject(calitm); 
} 

を終了したあなたが何か提案はありますか?あなたの時間のThnx ...

答えて

0

コードが存在する場合は、Saveメソッドの呼び出し中に何かクラッシュすることを意味します。

あなたが実際にあなたが保存できるように、あなたのフォルトコードをキャッチ/しようとする必要がある

は/あなたの例外再スローあなたは、保存、出力したり、例外を再スローどういう

for (int i = 0; i < filterAppointmentsToChangeLocation.RecordCount; i++) 
{ 
    int selrow = 1 
    var calitm = filterAppointmentsToChangeLocation.data[selrow].GetOlAppointment(); 

    try 
    { 
     calitm.UserProperties["location"].Value = extracted; 
     calitm.Save(); 
    } 
    catch (Exception e) 
    { 
     // save, output or retrhow your exception. 
     System.IO.File.WriteAllText (@"C:\somepath\error.txt", e.Message); 
    } 
    Marshal.ReleaseComObject(calitm); 
} 
+0

。それぞれの方法は何をしますか?私は貯蓄を再試行できますか?各項目に保存を実行することが重要です。 –

+0

こちらをご覧くださいhttp://stackoverflow.com/questions/14973642/how-using-try-catch-for-exception-handling-is-best-practiceあなたが例外を渡すことでできること。あなたはあなたのセーブを再生しようとするか、または例外を再利用してforループを止めることができます – bsoulier

関連する問題