public DeleteResolution ResolveDelete(OutlookContactInfo outlookContact) { string name = ContactMatch.GetName(outlookContact); _form.Text = "Google Contact deleted"; _form.messageLabel.Text = "Google Contact \"" + name + "\" doesn't exist anymore. Do you want to delete it also on Outlook side?"; _form.OutlookItemTextBox.Text = string.Empty; _form.GoogleItemTextBox.Text = string.Empty; Microsoft.Office.Interop.Outlook.ContactItem item = outlookContact.GetOriginalItemFromOutlook(); try { _form.OutlookItemTextBox.Text = ContactMatch.GetSummary(item); } finally { if (item != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(item); item = null; } } _form.keepOutlook.Text = "Keep Outlook"; _form.keepGoogle.Text = "Delete Outlook"; _form.skip.Enabled = false; return(ResolveDeletedGoogle()); }
internal void AddOutLookUsers() { var newUsers = from d in domainUsers where !(from o in outlookUsers select o.NickName) .Contains(d.NickName) select d; Microsoft.Office.Interop.Outlook.MAPIFolder folder = outlookApp.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts); foreach (var user in newUsers) { Microsoft.Office.Interop.Outlook.ContactItem item = (Microsoft.Office.Interop.Outlook.ContactItem)folder.Items.Add(Microsoft.Office.Interop.Outlook.OlItemType.olContactItem); item.MobileTelephoneNumber = user.MobileTelephoneNumber; item.CompanyName = user.CompanyName; item.OfficeLocation = user.OfficeLocation; item.FirstName = user.FirstName; item.ManagerName = user.ManagerName; item.Account = user.Account; item.BusinessTelephoneNumber = user.BusinessTelephoneNumber; item.Department = user.Department; item.FullName = user.FullName; item.Email1Address = user.EmailAddress; item.JobTitle = user.JobTitle; item.LastName = user.LastName; item.NickName = user.NickName; string filename = string.Empty; try { filename = AddPhoto(user.NickName, user.Picture); if (!string.IsNullOrEmpty(filename)) { item.AddPicture(filename); } } catch { } item.Categories = Properties.Settings.Default.Categories; item.Save(); // Cleanup if (!string.IsNullOrEmpty(filename)) { DeletePhoto(filename); } } }
internal void UpdateOutlookUsers() { var updateUsers = from o in outlookUsers from d in domainUsers where o.NickName == d.NickName select new { o, d }; Microsoft.Office.Interop.Outlook.MAPIFolder folder = outlookApp.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts); foreach (var user in updateUsers) { Microsoft.Office.Interop.Outlook.ContactItem item = folder.Items[user.o.Id]; item.MobileTelephoneNumber = user.d.MobileTelephoneNumber; item.CompanyName = user.d.CompanyName; item.OfficeLocation = user.d.OfficeLocation; item.FirstName = user.d.FirstName; item.ManagerName = user.d.ManagerName; item.Account = user.d.Account; item.BusinessTelephoneNumber = user.d.BusinessTelephoneNumber; item.Department = user.d.Department; item.FullName = user.d.FullName; item.Email1Address = user.d.EmailAddress; item.JobTitle = user.d.JobTitle; item.LastName = user.d.LastName; item.NickName = user.d.NickName; string filename = string.Empty; try { filename = AddPhoto(user.d.NickName, user.d.Picture); if (!string.IsNullOrEmpty(filename)) { item.AddPicture(filename); } } catch { } item.Save(); // cleanup if (!string.IsNullOrEmpty(filename)) { DeletePhoto(filename); } } }
public ConflictResolution Resolve(ContactMatch match, bool isNewMatch) { string name = match.ToString(); if (isNewMatch) { _form.messageLabel.Text = "This is the first time these Outlook and Google Contacts \"" + name + "\" are synced. Choose which you would like to keep."; _form.skip.Text = "Keep both"; } else { _form.messageLabel.Text = "Both the Outlook Contact and the Google Contact \"" + name + "\" have been changed. Choose which you would like to keep."; } _form.OutlookItemTextBox.Text = string.Empty; _form.GoogleItemTextBox.Text = string.Empty; if (match.OutlookContact != null) { Microsoft.Office.Interop.Outlook.ContactItem item = match.OutlookContact.GetOriginalItemFromOutlook(); try { _form.OutlookItemTextBox.Text = ContactMatch.GetSummary(item); } finally { if (item != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(item); item = null; } } } if (match.GoogleContact != null) { _form.GoogleItemTextBox.Text = ContactMatch.GetSummary(match.GoogleContact); } return(Resolve()); }
public void fetchOutlookContacts() { Microsoft.Office.Interop.Outlook.Items OutlookItems; Microsoft.Office.Interop.Outlook.Application outlookObj; MAPIFolder Folder_Contacts; outlookObj = new Microsoft.Office.Interop.Outlook.Application(); Folder_Contacts = (MAPIFolder)outlookObj.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts); OutlookItems = Folder_Contacts.Items; DataTable dt = new DataTable(); dt.Columns.Add("Email Address"); for (int i = 0; i < OutlookItems.Count; i++) { Microsoft.Office.Interop.Outlook.ContactItem contact = (Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i + 1]; dt.Rows.Add(new object[] { contact.Email1Address }); } dataGridView1.DataSource = dt; dataGridView1.Show(); }
public ConflictResolution ResolveDuplicate(OutlookContactInfo outlookContact, List <Contact> googleContacts, out Contact googleContact) { string name = ContactMatch.GetName(outlookContact); _form.messageLabel.Text = "There are multiple Google Contacts (" + googleContacts.Count + ") matching unique properties for Outlook Contact \"" + name + "\". Please choose from the combobox below the Google Contact you would like to match with Outlook and if you want to keep the Google or Outlook properties of the selected contact."; _form.OutlookItemTextBox.Text = string.Empty; _form.GoogleItemTextBox.Text = string.Empty; Microsoft.Office.Interop.Outlook.ContactItem item = outlookContact.GetOriginalItemFromOutlook(); try { _form.OutlookItemTextBox.Text = ContactMatch.GetSummary(item); } finally { if (item != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(item); item = null; } } _form.GoogleComboBox.DataSource = googleContacts; _form.GoogleComboBox.Visible = true; _form.AllCheckBox.Visible = false; _form.skip.Text = "Keep both"; ConflictResolution res = Resolve(); googleContact = _form.GoogleComboBox.SelectedItem as Contact; return(res); }
internal void GetOutlookUsers() { Microsoft.Office.Interop.Outlook.MAPIFolder folder = outlookApp.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts); outlookUsers.Clear(); for (int i = folder.Items.Count; i > 0; i--) { try { Microsoft.Office.Interop.Outlook.ContactItem user = folder.Items[i]; if (user.Categories == Properties.Settings.Default.Categories) { var item = new UserDetailsModel { Id = i, MobileTelephoneNumber = user.MobileTelephoneNumber, CompanyName = user.CompanyName, OfficeLocation = user.OfficeLocation, FirstName = user.FirstName, ManagerName = user.ManagerName, Account = user.Account, BusinessTelephoneNumber = user.BusinessTelephoneNumber, Department = user.Department, FullName = user.FullName, EmailAddress = user.Email1Address, JobTitle = user.JobTitle, LastName = user.LastName, NickName = user.NickName, }; outlookUsers.Add(item); } } catch { } } }
public ConflictResolution Resolve(Microsoft.Office.Interop.Outlook.ContactItem outlookContact, Google.GData.Contacts.ContactEntry googleContact) { _form.messageLabel.Text = "Both the outlook contact and the google contact \"" + googleContact.Title.Text + "\" has been changed. Choose which you would like to keep."; switch (_form.ShowDialog()) { case System.Windows.Forms.DialogResult.Cancel: // cancel return(ConflictResolution.Cancel); case System.Windows.Forms.DialogResult.No: // google wins return(ConflictResolution.GoogleWins); case System.Windows.Forms.DialogResult.Yes: // outlook wins return(ConflictResolution.OutlookWins); default: throw new Exception(); } }