我将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文件?有什么建议吗?