Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search contacts in Outlook

Status
Not open for further replies.

alexbo

Programmer
Jul 26, 2002
20
IT
Hi,
I have a little question:
with the the following code I created a contact in outlook:
Outlook.ApplicationClass App;
App= new Outlook.ApplicationClass();
Outlook.ContactItemClass Contatto= (Outlook.ContactItemClass)App.CreateItem(Outlook.OlItemType.olContactItem);
Contatto.FullName=FirstName.Text+" "+LastName.Text;
Contatto.Email1Address=EMail.Text;
Contatto.HomeTelephoneNumber=Phone.Text;
Contatto.HomeAddress=Address.Text;
Contatto.HomeAddressCity=City.Text;
Contatto.HomeAddressPostalCode=ZipCode.Text;
Contatto.HomeAddressState=State.Text;
Contatto.Close(Outlook.OlInspectorClose.olSave);

my problem is the following:
Since this procedure is made by an application that retrives data from a SQL Database, and each time that the user saves the records, it saves it automaticaly in outlook too, I need to know if there is a way to find out if the contact all ready exists, in which case I'll skip it.
I found an object called Outlook.Explores, but I don't know how to use it
can someone help ?

Thanks Alex
 
try
{
string entryID = string.Empty;
Outlook.ApplicationClass m_app;

m_app = new Outlook.ApplicationClass();

Outlook.ContactItemClass contact = (Outlook.ContactItemClass)m_app.GetNamespace("MAPI").GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).Items.Add(Outlook.OlItemType.olContactItem);
contact.FullName = this.m_fullName;
contact.TelexNumber = this.m_telephone;
contact.MobileTelephoneNumber = this.m_mobilePhone;
contact.HomeFaxNumber = this.m_fax;
contact.Email1Address = this.m_email;
contact.HomeAddress = this.m_address;
contact.PrimaryTelephoneNumber = this.m_telephone;
contact.Close(Outlook.OlInspectorClose.olSave);
entryID = contact.EntryID;
this.m_entryID = contact.EntryID;
contact = null;
return entryID;
}
catch(Exception e)
{
throw new Exception(e.ToString());
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top