how to read vcf into DataTable C# or VB.net

KhaLeeL ZoURoB 1 Reputation point
2021-02-16T15:40:32.09+00:00

i have file in .vcf format how can i read them into datatable or import into data grid view

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,278 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,576 Reputation points
    2021-02-28T06:14:03.697+00:00

    If office is already installed on your machine, you can also install Microsoft.Office.Interop.Outlook, and then add an extension method to the code, like this:

        class Program  
        {  
            static void Main(string[] args)  
            {  
                ContactItem contact;  
                Application app = new Application();  
      
                contact = (ContactItem)app.Session.OpenSharedItem(@"d:\1.vcf");  
      
                DataTable dataTable = new DataTable();  
      
                dataTable.Columns.Add("CompanyName", typeof(string));  
                dataTable.Columns.Add("E-Mail", typeof(string));  
                dataTable.AddToDatatable(contact);  
      
                Console.WriteLine();  
            }  
      
        }  
        public static class MyClass  
        {  
            public static void AddToDatatable(this DataTable dataTable, ContactItem contactItem)   
            {  
                dataTable.Rows.Add(contactItem.CompanyName,contactItem.Email1Address);  
            }  
        }  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments