.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to search in Global Address list in outlook using C#, am using the following code

Posted By: aakansha23     Posted Date: November 25, 2013    Points:5   Category :C#
Microsoft.Office.Interop.Outlook.AddressList gal =
new Microsoft.Office.Interop.Outlook.Application().Session.GetGlobalAddressList();

if (gal != null)
{
//ONLY 100 CONTACTS WILL BE ADDED CHANGE THIS AS PER YOUR REQUIREMENT
for (int i = 1;i <= Math.Min(100, gal.AddressEntries.Count - 1); i++)
{
Microsoft.Office.Interop.Outlook.AddressEntry addrEntry =gal.AddressEntries[i];

if (addrEntry.AddressEntryUserType ==Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeUserAddressEntry
|| addrEntry.AddressEntryUserType ==Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.olExchangeRemoteUserAddressEntry)
{
Microsoft.Office.Interop.Outlook.ExchangeUser exchUser =addrEntry.GetExchangeUser();
//ADDED IN LISTBOX
listBox1.Items.Add(exchUser.PrimarySmtpAddress + " " + exchUser.MobileTelephoneNumber);
}
//if (addrEntry.AddressEntryUserType ==
// Microsoft.Office.Interop.Outlook.OlAddressEntryUserType.
// olExchangeDistributionListAddressEntry)
//{
// Microsoft.Office.Interop.Outlook.ExchangeDistributionList exchDL =
// addrEntry.GetExchangeDistributionList();
// listBox1.Items.Add(exchDL.Name + " "+ exchDL.PrimarySmtpAddress );
//}
}
}
}

Responses

No response found. Be the first to respond this post
Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend