Advertisement
Advertisement
| 06.20.2008 at 10:39PM PDT, ID: 23504215 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: |
private void btnSearch_Click(object sender, EventArgs e)
{
int linenumber=68;
searchResultList.Clear();
bool bloop = false;
string owner="";
OutLook.Items contactItems = null;
try
{
linenumber=68;
OutLook.Application outapp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
OutLook.NameSpace outnamespace = outapp.GetNamespace("MAPI");
OutLook.MAPIFolder contactsFolder = outnamespace.GetDefaultFolder (OutLook.OlDefaultFolders.olFolderContacts);
contactItems = contactsFolder.Items;
owner = outnamespace.CurrentUser.AddressEntry.Name;
linenumber=74;
}
catch
{
MessageBox.Show("Either Outlook is not available or Outlook has reject your request for connection.", "Outlook Search", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
try
{
if (contactItems.Count == 1 )
{
OutLook.ContactItem contact = (OutLook.ContactItem)contactItems.GetFirst();// .GetNext();
linenumber=87;
if (contact.FirstName.ToUpper().StartsWith(txtSearchBox.Text.Trim().ToUpper()))
{
linenumber = 90;
Result searchresult = new Result();
string name = contact.Title + " " + contact.FirstName + " " + contact.MiddleName + " " + contact.LastName;
searchresult.showResult(name, contact.CompanyName, contact.Email1Address, contact.MobileTelephoneNumber);
searchresult.ShowDialog();
linenumber = 95;
}
}
else if (contactItems.Count > 1)
{
bool found = false;
linenumber = 101;
foreach (OutLook.ContactItem items in contactItems)
{
if (items.FirstName.ToUpper().StartsWith(txtSearchBox.Text.Trim().ToUpper()))
{
linenumber = 104;
object matcheditems = items;
searchResultList.Add(matcheditems);
found = true;
linenumber = 109;
}
}
linenumber = 113;
if (found == false)
{
MessageBox.Show("No record found matching your criteria. Please verify specified search criteria.", "Outlook Contact", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
if (searchResultList.Count == 1)
{
linenumber = 122;
OutLook.ContactItem cntct = (OutLook.ContactItem)searchResultList[0];
Result searchresult = new Result();
string name = cntct.Title + " " + cntct.FirstName + " " + cntct.MiddleName + " " + cntct.LastName;
searchresult.showResult(name, cntct.CompanyName, cntct.Email1Address, cntct.MobileTelephoneNumber);
searchresult.ShowDialog();
linenumber = 128;
}
else
{
linenumber = 132;
MatchList matchlist= new MatchList(searchResultList);
matchlist.showMatchList();
matchlist.ShowDialog();
linenumber = 136;
}
}
}
else
MessageBox.Show("No record found matching your criteria. Please verify specified search criteria.", "Outlook Contact", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("Exception after Line No. : " +linenumber.ToString()+" for "+ex.Message+"\nTotal match found "+searchResultList.Count.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
|