public Contact GetCanonicalContact(RDOContactItem ctc) { if (ctc == null) return null; Contact contact = new Contact(); contact.Names.Add(new Name(ctc.FirstName, ctc.MiddleName, ctc.LastName, NameCatenationOrder.FamilyGivenMiddle)); PhoneNumber phone = null; EmailAddress email = null; if (ctc.MobileTelephoneNumber != null && ctc.MobileTelephoneNumber.Trim() != "") { phone = new PhoneNumber(ctc.MobileTelephoneNumber); contact.PhoneNumbers.Add(phone, PhoneLabels.Cellular); } if (ctc.HomeTelephoneNumber != null && ctc.HomeTelephoneNumber.Trim() != "") { phone = new PhoneNumber(ctc.HomeTelephoneNumber); contact.PhoneNumbers.Add(phone, PhoneLabels.Voice, PropertyLabels.Personal); } if (ctc.BusinessTelephoneNumber != null && ctc.BusinessTelephoneNumber.Trim() != "") { phone = new PhoneNumber(ctc.BusinessTelephoneNumber); contact.PhoneNumbers.Add(phone, PhoneLabels.Voice, PropertyLabels.Business); } if (ctc.Email1Address != null && ctc.Email1Address.Trim() != "") { email = new EmailAddress(ctc.Email1Address); contact.EmailAddresses.Add(email, PropertyLabels.Preferred); } if (ctc.Email2Address != null && ctc.Email2Address.Trim() != "") { email = new EmailAddress(ctc.Email2Address); contact.EmailAddresses.Add(email, PropertyLabels.Personal); } if (ctc.Email3Address != null && ctc.Email3Address.Trim() != "") { email = new EmailAddress(ctc.Email3Address); contact.EmailAddresses.Add(email, PropertyLabels.Business); } DateTime lastChanged = ctc.LastModificationTime.ToUniversalTime(); contact.Dates.Add(lastChanged, new string[] { "LastModificationTime" }); Guid hi = new Guid(ctc.EntryID.Substring(0, 16).PadLeft(32, '0')); Guid lo = new Guid(ctc.EntryID.Substring(16, 32)); contact.ContactIds.Add(hi, new string[] { "OutlookIdHi" }); contact.ContactIds.Add(lo, new string[] { "OutlookIdLo" }); return contact; }
public void FillProviderCreatedItem(Contact contact, RDOContactItem ctc) { // Outlook has just One Name if (contact.Names.Count > 0) { Name name = contact.Names[0]; //name = GetCannonicalName(name.FormattedName, // name.GivenName, name.MiddleName, name.FamilyName, // NameNotation.Formal, NameNotation.Formal); name.PersonalTitle = contact.Names[0].PersonalTitle; name.Prefix = contact.Names[0].Prefix; name.Suffix = contact.Names[0].Suffix; ctc.FullName = name.FormattedName; ctc.FirstName = name.GivenName; ctc.MiddleName = name.MiddleName; ctc.LastName = name.FamilyName; ctc.NickName = name.Nickname; ctc.Suffix = name.Generation + (name.Generation == null ? "" : " " ) + name.Suffix; ctc.Title = name.Prefix + (name.Prefix == null || name.Prefix == "" ? "" : " ") + name.PersonalTitle; } /// Outlook Possible Phone Numbers // ctc.BusinessFaxNumber business fax // ctc.BusinessTelephoneNumber buisness voice // ctc.Business2TelephoneNumber business voice // ctc.HomeFaxNumber personal fax // ctc.HomeTelephoneNumber personal voice // ctc.Home2TelephoneNumber personal voice // ctc.MobileTelephoneNumber cell // ctc.OtherTelephoneNumber // ctc.PrimaryTelephoneNumber primary // ctc.CarTelephoneNumber // ctc.ISDNNumber isdn // ctc.PagerNumber pager // ctc.CallbackTelephoneNumber // ctc.TelexNumber //for (int i = 0; i < contact.PhoneNumbers.Count; i++) //{ // ILabelCollection labels = contact.PhoneNumbers.GetLabelsAt(i); // PhoneNumber ph = contact.PhoneNumbers[i]; // if (labels.Contains("Cellular")) // { // ctc.MobileTelephoneNumber = ph; // } else if () //} if (contact.PhoneNumbers["Cellular"] != null) ctc.MobileTelephoneNumber = contact.PhoneNumbers["Cellular"].Number; if (contact.PhoneNumbers["Voice", "Personal"] != null) ctc.HomeTelephoneNumber = contact.PhoneNumbers["Voice", "Personal"].Number; if (contact.PhoneNumbers["Voice", "Business"] != null) ctc.BusinessTelephoneNumber = contact.PhoneNumbers["Voice", "Business"].Number; if (contact.Positions["Business"] != null) { ctc.JobTitle = contact.Positions["Business"].JobTitle; ctc.OfficeLocation = contact.Positions["Business"].Office; ctc.CompanyName = contact.Positions["Business"].Company; ctc.Department = contact.Positions["Business"].Department; } if (contact.EmailAddresses.Count > 0) ctc.Email1Address = contact.EmailAddresses[0].Address; if (contact.EmailAddresses.Count > 1) ctc.Email2Address = contact.EmailAddresses[1].Address; if (contact.EmailAddresses.Count > 2) ctc.Email3Address = contact.EmailAddresses[2].Address; }