我将 Outlook 联系人导出到 .csv 文件并将所有 Outlook 联系人放入List<Outlook.ContactItem> contactItems
我创建了一个名为 ConvertToCSV() 的方法来提取特定联系人的每个属性。在此方法中,我们将每个联系人的属性添加到 List 中,如下代码所示:
private void ConvertToCSV(List<Outlook.ContactItem> contactItems)
{
using (var file = File.CreateText(@"D:\ExportContacts1.CSV"))
{
file.WriteLine(ContactItemsListToCSV());
foreach (var arr in contactItems)
{
List<string> list = new List<string>();
list.Add(arr.Title);
list.Add(arr.FirstName);
list.Add(arr.MiddleName);
list.Add(arr.LastName);
list.Add(arr.BusinessAddress);
list.Add(arr.BusinessAddressStreet);
list.Add(arr.BusinessAddressCity);
list.Add(arr.BusinessAddressState);
list.Add(arr.BusinessAddressPostalCode);
list.Add(arr.BusinessAddressCountry);
//and other properties of Outlook ContactItem
file.WriteLine(list[0] + "," + list[1] + "," + list[2] + "," + list[3]);
//adding other list items too
}
当我看到 Outlook 创建的 .csv 文件时,我看到三个属性:Business street, Business Street 2, Business Street 3
. 在上面的代码中我应该绑定哪一个?在 Outlook 联系人中,我会看到树结构为:
Business Address
Business Street
Business Street 2
Business Street 3
...and so on
如何从 Outlook 访问这些属性,以便获得与 Outlook 生成的相同的 .csv 文件?有什么建议么?