Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am exporting Outlook contacts to .csv file and took all Outlook contacts to

List<Outlook.ContactItem> contactItems


created a method called ConvertToCSV() to extract each property of particular contact.In this Method am adding each contact's properties to List as shown below code.
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        
  } 

when i see the .csv file created by outlook,in that i could find
<pre lang="xml">Business street, Business Street 2,Business Street 3
</pre>


for this Business Street which property i need to bind in the above code.In outlook contacts, i had seen like tree structure as

Business Address
          Business Street
          Business Street 2
          Business Street 3
          ...and so on

attaching the image too.How can i access these properties from Outlook.Application so that i can get the same .csv file as the Outlook generates..any suggestion please
Posted
Updated 24-Jul-13 4:33am
v2

1 solution

 
Share this answer
 
v2
Comments
keerth516 25-Jul-13 7:47am    
Thanks for the reply .I had gone through this link also and understood this way.When i use "BusinessAddress" it returns Fulladdress,if i use "BusinessAddressStreet" property it returns only Street details. Can you please suggest me how should i get this Business Street 2 and Business Street 3 property as it shows in actual .csv file generated by Outlook 2007
Richard MacCutchan 25-Jul-13 7:52am    
If you look closely at the link I provided you will see that these items are not exposed by the .NET interop classes. You will have to take the full address and split it for yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900