私は WPF-C# アプリケーションを開発しており、Redemption を使用して MS Outlook 2010 の連絡先アイテムを取得しています。Outlook に SMTP アカウントが 1 つしかない場合、問題なく動作しています。しかし、Exchange サーバー アカウントである別のアカウントを構成すると、同じコードから連絡先アイテムを取得できません。以下は私のコードです:
Interop.Redemption.RDOItems folderItems = null;
Interop.Redemption.RDOFolder folderContacts = null;
Interop.Redemption.RDOFolder folderSuggestedContacts = null;
List<GMContactItem> allOutlookContacts = null;
object itemObj = null;
List<Interop.Redemption.RDOContactItem> contactItemsList = null;
try
{
folderContacts = (RDOFolder)RDOSessionItem.GetDefaultFolder(Interop.Redemption.rdoDefaultFolders.olFolderContacts);
contactItemsList = new List<RDOContactItem>();
folderItems = folderContacts.Items;
for (int i = 1; folderItems.Count >= i; i++)
{
itemObj = folderItems[i];
if (itemObj is Interop.Redemption.RDOContactItem)
contactItemsList.Add(itemObj as RDOContactItem);
else
Marshal.ReleaseComObject(itemObj);
}
Marshal.ReleaseComObject(folderItems);
folderItems = null;
// getting items from the Suggested Contacts folder in Outlook
folderSuggestedContacts = RDOSessionItem.GetDefaultFolder(
rdoDefaultFolders.olFolderSuggestedContacts);
if (folderSuggestedContacts != null)
{
folderItems = folderSuggestedContacts.Items;
for (int i = 1; folderItems.Count >= i; i++)
{
itemObj = folderItems[i];
if (itemObj is Interop.Redemption.RDOContactItem)
contactItemsList.Add(itemObj as Interop.Redemption.RDOContactItem);
else
Marshal.ReleaseComObject(itemObj);
}
}
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
Exchange サーバー アカウントを削除すると正常に動作し、Outlook に Exchange サーバー アカウントを追加すると、このコードに例外はありませんが、連絡先アイテムは表示されません。ここで何が問題になる可能性があるのか 誰かが私に提案できますか. 前もって感謝します。
-スーリヤ