Sunil Goud

Sunil Goud

  • NA
  • 18
  • 45.5k

Importing contacts from outlook 2011

Sep 7 2011 6:32 AM
I have written a code in C3 for getting all contacts from outlook 2007 which works fine, but it not import contacts from outlook 2010 
my code is as follow 


try

{

comboencoding.Enabled =

OutLook.

outlookObj.ActiveExplorer();

OutLook.

comboDelimiter.Properties.Items.Clear();


{

comboDelimiter.SelectedText =

comboDelimiter.Properties.Items.Add(

}


false;_Application outlookObj = new OutLook.Application();MAPIFolder contactsFolder = (OutLook.MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);if (!comboDelimiter.Properties.Items.Contains("Default"))"Default";"Default");//VERIFYING THE CUSTOM FOLDER IN OUT LOOK .


{


{

comboDelimiter.Properties.Items.Add(subFolder.Name);

}

}


foreach (OutLook.MAPIFolder subFolder in contactsFolder.Folders)if (!comboDelimiter.Properties.Items.Contains(subFolder.Name))// Add items to ComboCondition

comboCondition.Properties.Items.Clear();


{

comboCondition.Properties.Items.Add(list[i]);

}

}


{



}

}

for (int i = 3; i <= 14; i++)catch (System.Exception ex)Console.WriteLine(ex);XtraMessageBox.Show(ex.Message);

#region


{




"GetContacts from Selected Folder of Outlook"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.

OutLook.


{

fldContacts = (OutLook.

}


MAPIFolder fldContacts = null;_Application outlookObj = new OutLook.Application();if (folderName == "Default")MAPIFolder)outlookObj.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts);else

{

OutLook.

outlookObj.Session.GetDefaultFolder(OutLook.


MAPIFolder contactsFolder = (OutLook.MAPIFolder)OlDefaultFolders.olFolderContacts);//VERIFYING THE CUSTOM FOLDER IN OUT LOOK .


{


{

fldContacts = subFolder;


}

}

}



{

dt.Columns.Add(

}


{

{


dr[0] =

dr[1] =

dr[2] =


dr[3] = contactItem.Email1Address;


foreach (OutLook.MAPIFolder subFolder in contactsFolder.Folders)if (subFolder.Name == folderName)break;DataTable dt = new DataTable();for (int i = 0; i < 12; i++)"Col" + i,Type.GetType ("System.String"));foreach (Microsoft.Office.Interop.Outlook._ContactItem contactItem in fldContacts.Items)DataRow dr = dt.NewRow();Convert.ToString(contactItem.FirstName);Convert.ToString(contactItem.LastName);Convert.ToString(contactItem.MobileTelephoneNumber);if (!string.IsNullOrEmpty(contactItem.Email1Address))else

dr[3] = contactItem.Email2Address;

dr[4] =

dr[5] =

dr[6] =

dr[7] =

dr[8] =

dr[9] =

dr[10] =

dr[11] =

dt.Rows.Add(dr);

}

}

ds.Tables.Add(dt);

}


{


}


}

Convert.ToString(contactItem.HomeAddress);Convert.ToString(contactItem.BusinessTelephoneNumber);Convert.ToString(contactItem.HomeTelephoneNumber);Convert.ToString(contactItem.CompanyName);Convert.ToString(contactItem.Birthday);Convert.ToString(contactItem.Anniversary);Convert.ToString(contactItem.JobTitle);Convert.ToString(contactItem.HomeFaxNumber);catch (System.Exception ex)Console.WriteLine(ex);return ds;

what is the problem?
thanks............ 

Answers (1)