Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:55:09+00:00 2026-05-25T10:55:09+00:00

I created code for importing contact from outlook. Created application in .net framework with

  • 0

I created code for importing contact from outlook. Created application in .net framework with version 4.0 in C#.

code is as follows –

OutLook._Application outlookObj = new OutLook.Application();
outlookObj.ActiveExplorer();
OutLook.MAPIFolder contactsFolder = (OutLook.MAPIFolder)outlookObj.Session
    .GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);
comboDelimiter.Properties.Items.Clear();
if (!comboDelimiter.Properties.Items.Contains("Default"))
{
    comboDelimiter.SelectedText = "Default";
    comboDelimiter.Properties.Items.Add("Default");
}
//VERIFYING THE CUSTOM FOLDER IN OUT LOOK .
foreach (OutLook.MAPIFolder subFolder in contactsFolder.Folders)
{
    if (!comboDelimiter.Properties.Items.Contains(subFolder.Name))
    {
        comboDelimiter.Properties.Items.Add(subFolder.Name);
    }
}

This function is used for reading contacts from the particular folder of the outlook contact –

private DataSet GetContactsFromFolder(string folderName)
{
    object missing = System.Reflection.Missing.Value;
    DataSet ds = new DataSet();
    //create instance of Outlook application and Outlook Contacts folder.
    try
    {
        OutLook.MAPIFolder fldContacts = null;
        OutLook._Application outlookObj = new OutLook.Application();
        if (folderName == "Default")
        {
            fldContacts = (OutLook.MAPIFolder)outlookObj.Session
                .GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);
        }
        else
        {

            OutLook.MAPIFolder contactsFolder = (OutLook.MAPIFolder)outlookObj.Session
                .GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);
            //VERIFYING THE CUSTOM FOLDER IN OUT LOOK .
            foreach (OutLook.MAPIFolder subFolder in contactsFolder.Folders)
            {
                if (subFolder.Name == folderName)
                {
                    fldContacts = subFolder;
                    break;
                }
            }
        }
        DataTable dt = new DataTable();
        for (int i = 0; i < 12; i++)
        {
            dt.Columns.Add("Col" + i,Type.GetType ("System.String"));
        }
        foreach (Microsoft.Office.Interop.Outlook._ContactItem contactItem in fldContacts.Items)
        {
            {
                DataRow dr = dt.NewRow();
                dr[0] = Convert.ToString(contactItem.FirstName);
                dr[1] = Convert.ToString(contactItem.LastName);
                dr[2] = Convert.ToString(contactItem.MobileTelephoneNumber);
                if (!string.IsNullOrEmpty(contactItem.Email1Address))
                    dr[3] = contactItem.Email1Address;
                else
                    dr[3] = contactItem.Email2Address;
                dr[4] = Convert.ToString(contactItem.HomeAddress);
                dr[5] = Convert.ToString(contactItem.BusinessTelephoneNumber);
                dr[6] = Convert.ToString(contactItem.HomeTelephoneNumber);
                dr[7] = Convert.ToString(contactItem.CompanyName);
                dr[8] = Convert.ToString(contactItem.Birthday);
                dr[9] = Convert.ToString(contactItem.Anniversary);
                dr[10] = Convert.ToString(contactItem.JobTitle);
                dr[11] = Convert.ToString(contactItem.HomeFaxNumber);
                dt.Rows.Add(dr);
            }
        }
        ds.Tables.Add(dt);
    }
    catch (System.Exception ex)
    {
        Console.WriteLine(ex);
    }
    return ds;
}

I added dll for this ,is of Microsoft.Office.Interop.Outlook with version 9.2 Description is Microsoft.Office 11.0 Object Library

It imports contact from outlook 2007 version but
when i’m importing contact from outlook 2010 then it is not importing contact.

How to resolve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:55:10+00:00Added an answer on May 25, 2026 at 10:55 am

    You are working with version specific MS Office interop components.

    What you need to use is a non-version specific MS Office framework/library such as:

    NetOffice – The easiest way to use Office in .NET
    http://netoffice.codeplex.com/

    .NET Wrapper Assemblies for accessing Microsoft Office, Excel, Word, Outlook, PowerPoint, Access, Project

    With features such as:

    • Office integration without version limitations
    • All objects, methods,
      properties and events of the Office versions 2000, 2002, 2003, 2007,
      2010
      are included
    • Syntactically and semantically identical to the Microsoft Interop Assemblies No deployment hurdles, no problematic registration, no dependencies, no interop assemblies, no need for VSTO

    There is an example of how to get a list of Outlook contacts in C# here:
    http://netoffice.codeplex.com/wikipage?title=Outlook_Example05

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created the following code to calculate the duration between two timestamps which can
I have created an iframe code that I want people to use as a
I have a project where a .master page was created without a code behind
How and at what stage is a valid OpenGL context created in my code?
I created a single page (with code behind .vb) and created Public intFileID As
I created a grid in procedural code on my WPF page. Now I want
I created an ASMX file with a code behind file. It's working fine, but
The code is rather long yet simple: 100 leaky JavaScript objects are created. 10
How are DLLs created out of C++ source code, and how are they used
when a dll is created out of the source code in a given namespaces

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.