private void FindContactEmailByName(string firstName, string lastName) { Outlook.NameSpace outlookNameSpace = this.Application.GetNamespace("MAPI"); Outlook.MAPIFolder contactsFolder = outlookNameSpace.GetDefaultFolder( Microsoft.Office.Interop.Outlook. OlDefaultFolders.olFolderContacts); Outlook.Items contactItems = contactsFolder.Items; try { Outlook.ContactItem contact = (Outlook.ContactItem)contactItems. Find(String.Format("[FirstName]='{0}' and " + "[LastName]='{1}'", firstName, lastName)); if (contact != null) { contact.Display(true); } else { MessageBox.Show("The contact information was not found."); } } catch (Exception ex) { throw ex; } }
private OutLook.ContactItem checkForUpdatedItemsInDB() { Microsoft.Office.Interop.Outlook.Items OutlookItems; //OutLook.MAPIFolder Folder_Contacts; // Folder_Contacts = (OutLook.MAPIFolder)OutLookApp.Session.GetDefaultFolder(OutLook.OlDefaultFolders.olFolderContacts); OutlookItems = folder.Items; progressBar1.Maximum = folder.Items.Count; for (int i = 1; i < OutlookItems.Count; i++) { object missing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Outlook.ContactItem contact = (Microsoft.Office.Interop.Outlook.ContactItem)OutlookItems[i]; if (progressBar1.Value < progressBar1.Maximum) { MethodInvoker m = new MethodInvoker(() => progressBar1.Value++); progressBar1.Invoke(m); } if (contact != null) { OutLook.UserProperty userProperty2 = contact.UserProperties.Find("Organizational ID", missing); if (userProperty2 != null && userProperty2.Value != string.Empty) { if (!ifExistsInDB(userProperty2.Value)) { contact.Delete(); } } } } MethodInvoker m2 = new MethodInvoker(() => progressBar1.Value = 0); progressBar1.Invoke(m2); return(null); }
// Occurs before the form region is displayed. // Use this.OutlookItem to get a reference to the current Outlook item. // Use this.OutlookFormRegion to get a reference to the form region. private void ClearMessage_FormRegionShowing(object sender, System.EventArgs e) { dynamic outlookObject = (dynamic)this.OutlookItem; if (outlookObject.MessageClass == "IPM.Note") { chkSendViaClearMessage.Visible = false; } //Check the object is of type Contact if (outlookObject.MessageClass == "IPM.Contact") { chkSendViaClearMessage.Visible = true; Outlook.ContactItem contactItem = (Outlook.ContactItem) this.OutlookItem; //Getting the custom property defined for the checkbox var CustomProperty = contactItem.UserProperties.Find("SendViaClearMessage", true); if (CustomProperty != null) { //Setting the state of the checkbox from the property chkSendViaClearMessage.Checked = contactItem.UserProperties["SendViaClearMessage"].Value; } else { //This process will get exceuted if the old contact doesn't have the property. contactItem.UserProperties.Add("SendViaClearMessage", Outlook.OlUserPropertyType.olYesNo, true, Type.Missing); contactItem.UserProperties["SendViaClearMessage"].Value = chkSendViaClearMessage.Checked; contactItem.Subject = contactItem.LastNameAndFirstName; contactItem.Save(); } Marshal.FinalReleaseComObject(contactItem); } }
/// <summary> /// Get the CRM id for this item, if known, else the empty string. /// </summary> /// <param name="olItem">The Outlook item under consideration.</param> /// <returns>the CRM id for this item, if known, else the empty string.</returns> public static CrmId GetCrmId(this Outlook.ContactItem olItem) { Outlook.UserProperty property = olItem.UserProperties[SyncStateManager.CrmIdPropertyName]; CrmId result = property != null?CrmId.Get(property.Value) : CrmId.Empty; return(result); }
/// <summary> /// Set this item as manually syncable, briefly. As a side effect of making the change triggers sync. /// </summary> /// <remarks>In order to allow manual sync, we need to be able to override the disablement of syncing - /// but only briefly.</remarks> /// <param name="olItem">The item which may be synced despite syncing being disabled</param> public static void SetManualOverride(this Outlook.ContactItem olItem) { var p = olItem.UserProperties.Add(OverridePropertyName, Outlook.OlUserPropertyType.olDateTime); p.Value = DateTime.UtcNow; olItem.Save(); }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { Microsoft.Office.Interop.Outlook._Application OutlookObject = new Microsoft.Office.Interop.Outlook.Application(); //Create a new Contact Item Microsoft.Office.Interop.Outlook.ContactItem contact = OutlookObject.CreateItem( Microsoft.Office.Interop.Outlook.OlItemType.olContactItem); //Set different properties of this Contact Item. contact.FirstName = "Mellissa"; contact.LastName = "MacBeth"; contact.JobTitle = "Account Representative"; contact.CompanyName = "Contoso Ltd."; contact.OfficeLocation = "36/2529"; contact.BusinessTelephoneNumber = "4255551212 x432"; contact.BusinessAddressStreet = "1 Microsoft Way"; contact.BusinessAddressCity = "Redmond"; contact.BusinessAddressState = "WA"; contact.BusinessAddressPostalCode = "98052"; contact.BusinessAddressCountry = "United States of America"; contact.Email1Address = "*****@*****.**"; contact.Email1AddressType = "SMTP"; contact.Email1DisplayName = "Melissa MacBeth ([email protected])"; //Save the Contact to disc contact.SaveAs("OutlookContact.vcf", OlSaveAsType.olVCard); }
public bool CreateContact() { Outlook.ContactItem contact = OutlookSync.Syncer.CurrentApplication.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem; if (contact == null) { return(false); } contact.FirstName = Name; if (Email != null) { contact.Email1Address = Email; } if (Phone != null) { contact.HomeTelephoneNumber = Phone; } contact.Save(); return(true); }
private void AddDefaultContact() { Outlook.ContactItem newContact = (Outlook.ContactItem) this.Application.CreateItem(Outlook.OlItemType.olContactItem); try { newContact.FirstName = "Chris"; newContact.LastName = "Berry"; newContact.Email1Address = "*****@*****.**"; newContact.CustomerID = "123456"; newContact.PrimaryTelephoneNumber = "(425)555-0111"; newContact.MailingAddressStreet = "123 Main St."; newContact.MailingAddressCity = "Redmond"; var mailUserProperties = newContact.UserProperties; // Where 1 is OlFormatText (introduced in Outlook 2007) newContact.UserProperties.Add("CaseID", Outlook.OlUserPropertyType.olText, true, 1); newContact.UserProperties["CaseID"].Value = "1234567890123456"; //newContact.UserProperties["Case Id"].Value = "1234567890123456"; newContact.MailingAddressState = "WA"; newContact.Save(); newContact.Display(true); } catch { MessageBox.Show("The new contact was not saved."); } }
/// <summary> /// Allows to mark the selected task as completed (clear task flag for regular items) /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void mnuItemMarkComplete_Click(object sender, EventArgs e) { if (this.lstTasks.SelectedIndices.Count != 0) { OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem; if (task != null && !task.Completed) // Attempting to complete an already completed task throws an exception { if (MessageBox.Show("Are you sure you want to complete this task?", "Mark task as completed/Clear task flag", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (task.OriginalItem is Outlook.MailItem) { Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem; mail.ClearTaskFlag(); } else if (task.OriginalItem is Outlook.ContactItem) { Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem; contact.ClearTaskFlag(); } else if (task.OriginalItem is Outlook.TaskItem) { Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem; t.MarkComplete(); } else { // Do nothing } } // At the end, synchronously "refresh" tasks in case they have changed this.RetrieveTasks(); } } }
/// <summary> /// Open the task /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void lstTasks_DoubleClick(object sender, EventArgs e) { if (this.lstTasks.SelectedIndices.Count != 0) { OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem; if (task != null) { if (task.OriginalItem is Outlook.MailItem) { Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem; mail.Display(true); } else if (task.OriginalItem is Outlook.ContactItem) { Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem; contact.Display(true); } else if (task.OriginalItem is Outlook.TaskItem) { Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem; t.Display(true); } else { // Do nothing } // At the end, synchronously "refresh" tasks in case they have changed this.RetrieveTasks(); } } }
/// <summary> /// Allows to delete the selected task /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private void mnuItemDeleteTask_Click(object sender, EventArgs e) { if (this.lstTasks.SelectedIndices.Count != 0) { OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem; if (task != null) { if (MessageBox.Show("Are you sure you want to delete this task?", "Delete task", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (task.OriginalItem is Outlook.MailItem) { Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem; mail.Delete(); } else if (task.OriginalItem is Outlook.ContactItem) { Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem; contact.Delete(); } else if (task.OriginalItem is Outlook.TaskItem) { Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem; t.Delete(); } else { // Do nothing } } // At the end, synchronously "refresh" tasks in case they have changed this.RetrieveTasks(); } } }
private void DeleteExistingTestContacts(string name, string email) { sync.Load(); ContactsMatcher.SyncContacts(sync); ContactMatch match = sync.ContactByProperty(name, email); try { while (match != null) { if (match.GoogleContact != null) { match.GoogleContact.Delete(); } if (match.OutlookContact != null) { match.OutlookContact.Delete(); } sync.Load(); ContactsMatcher.SyncContacts(sync); match = sync.ContactByProperty(name, email); } } catch { } Outlook.ContactItem prevOutlookContact = sync.OutlookContacts.Find("[Email1Address] = '" + email + "'") as Outlook.ContactItem; if (prevOutlookContact != null) { prevOutlookContact.Delete(); } }
private void CreateContactExample(string first, string last) { try { Outlook.ContactItem contact = Application.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem; contact.FirstName = first; contact.LastName = last; contact.JobTitle = "Account Representative"; contact.CompanyName = "Contoso Ltd."; contact.OfficeLocation = "36/2529"; contact.BusinessTelephoneNumber = "4255551212 x432"; contact.WebPage = "http://www.contoso.com"; contact.BusinessAddressStreet = "1 Microsoft Way"; contact.BusinessAddressCity = "Redmond"; contact.BusinessAddressState = "WA"; contact.BusinessAddressPostalCode = "98052"; contact.BusinessAddressCountry = "United States of America"; contact.Email1Address = "*****@*****.**"; contact.Email1AddressType = "SMTP"; contact.Email1DisplayName = "Melissa MacBeth ([email protected])"; contact.Save(); } catch { MessageBox.Show("The new contact was not saved."); } }
private static void AddContactToEmailLookup(Outlook.ContactItem contact, Outlook.Folder contactsFolder) { if (contact.Email1Address is object) { if (!emailLookup.ContainsKey(contact.Email1Address)) { emailLookup.Add(contact.Email1Address.ToLower(), new Tuple <string, string>(contact.EntryID, contactsFolder.StoreID)); } } if (contact.Email2Address is object) { if (!emailLookup.ContainsKey(contact.Email2Address)) { emailLookup.Add(contact.Email2Address.ToLower(), new Tuple <string, string>(contact.EntryID, contactsFolder.StoreID)); } } if (contact.Email3Address is object) { if (!emailLookup.ContainsKey(contact.Email3Address)) { emailLookup.Add(contact.Email3Address.ToLower(), new Tuple <string, string>(contact.EntryID, contactsFolder.StoreID)); } } }
/// <summary> /// 获取 Outlook 地址簿列表. /// </summary> /// <returns></returns> public List <UserAddressBook> ReadAddressBookList() { List <UserAddressBook> resultList = new List <UserAddressBook>(); Outlook.NameSpace mynamespace = outlookApp.GetNamespace("MAPI"); Outlook.MAPIFolder myFolder = mynamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts); int iMailCount = myFolder.Items.Count; for (int k = 1; k <= iMailCount; k++) { Outlook.ContactItem item = (Outlook.ContactItem)myFolder.Items[k]; UserAddressBook result = new UserAddressBook(); // 姓名. result.UserName = item.LastName; // 邮件地址. result.Email = item.Email1Address; // 号码. result.Mobile = item.MobileTelephoneNumber; // 部门. result.Department = item.Department; // 加入列表. resultList.Add(result); } return(resultList); }
private static ContactItem FindContractFromOLAddrBook( Items contactItems, Contract contract) { Outlook.ContactItem contactItem = null; if (string.IsNullOrEmpty(contract.Code)) { contactItem = contactItems.Find( String.Format("[FullName]='{0}' AND [Department] ='{1}'", contract.Name, contract.Dept)) as Outlook.ContactItem; } else { contactItem = contactItems.Find( String.Format("[OrganizationalIDNumber]='{0}'", contract.Code)) as Outlook.ContactItem; } if (contactItem != null) { return(contactItem); } else { return(null); } }
public static Image GetOutlookPhoto(Outlook.ContactItem outlookContact) { if (!HasPhoto(outlookContact)) { return(null); } try { foreach (Outlook.Attachment a in outlookContact.Attachments) { if (a.DisplayName.ToUpper().Contains("CONTACTPICTURE") || a.DisplayName.ToUpper().Contains("CONTACTPHOTO")) { string fn = GetTempFileName("jpg"); a.SaveAsFile(fn); Image img = null; using (var fs = new FileStream(fn, FileMode.Open)) { img = Image.FromStream(fs); } File.Delete(fn); return(img); } } return(null); } catch { return(null); } }
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; Outlook.ContactItem item = outlookContact.GetOriginalItemFromOutlook(); try { _form.OutlookItemTextBox.Text = ContactMatch.GetSummary(item); } finally { if (item != null) { Marshal.ReleaseComObject(item); item = null; } } _form.keepOutlook.Text = "Keep Outlook"; _form.keepGoogle.Text = "Delete Outlook"; _form.skip.Enabled = false; return(ResolveDeletedGoogle()); }
public static void SetIMs(Outlook.ContactItem source, Contact destination) { destination.IMs.Clear(); if (!string.IsNullOrEmpty(source.IMAddress)) { //IMAddress are expected to be in form of ([Protocol]: [Address]; [Protocol]: [Address]) string[] imsRaw = source.IMAddress.Split(';'); foreach (string imRaw in imsRaw) { string[] imDetails = imRaw.Trim().Split(':'); IMAddress im = new IMAddress(); if (imDetails.Length == 1) { im.Address = imDetails[0].Trim(); } else { im.Protocol = imDetails[0].Trim(); im.Address = imDetails[1].Trim(); } //Only add the im Address if not empty (to avoid Google exception "address" empty) if (!string.IsNullOrEmpty(im.Address)) { im.Primary = destination.IMs.Count == 0; im.Rel = ContactsRelationships.IsHome; destination.IMs.Add(im); } } } }
/// <summary> /// Get the existing sync state for this item, if it exists and is of the appropriate /// type, else null. /// </summary> /// <remarks>Outlook items are not true objects and don't have a common superclass, /// so we have to use this rather clumsy overloading.</remarks> /// <param name="contact">The item.</param> /// <returns>The appropriate sync state, or null if none.</returns> /// <exception cref="UnexpectedSyncStateClassException">if the sync state found is not of the expected class (shouldn't happen).</exception> public ContactSyncState GetSyncState(Outlook.ContactItem contact) { SyncState result; try { result = this.byOutlookId.ContainsKey(contact.EntryID) ? this.byOutlookId[contact.EntryID] : null; CrmId crmId = CheckForDuplicateSyncState(result, contact.GetCrmId()); if (CrmId.IsValid(crmId)) { if (result == null && this.byCrmId.ContainsKey(crmId)) { result = this.byCrmId[crmId]; } else if (result != null && this.byCrmId.ContainsKey(crmId) == false) { this.byCrmId[crmId] = result; result.CrmEntryId = crmId; } } if (result != null && result as ContactSyncState == null) { throw new UnexpectedSyncStateClassException("ContactSyncState", result); } } catch (COMException) { // dead item passed. result = null; } return(result as ContactSyncState); }
// Occurs before the form region is displayed. // Use this.OutlookItem to get a reference to the current Outlook item. // Use this.OutlookFormRegion to get a reference to the form region. //<Snippet2> private void MapIt_FormRegionShowing(object sender, EventArgs e) { string tempLoc = ""; string defaultAddress = ""; string scratchPadAddress = ""; Outlook.ContactItem myItem = (Outlook.ContactItem) this.OutlookItem; if (myItem != null) { if (myItem.HomeAddress != null && myItem.HomeAddress.Trim().Length > 0) { tempLoc = myItem.HomeAddressStreet.Trim() + " " + myItem.HomeAddressCity + " " + myItem.HomeAddressState + " " + myItem.HomeAddressPostalCode; if (myItem.HomeAddress == myItem.MailingAddress) { defaultAddress = tempLoc + "_Home"; } else { scratchPadAddress += "adr." + tempLoc + "_Home~"; } } if (myItem.BusinessAddress != null && myItem.BusinessAddress.Trim().Length > 0) { tempLoc = myItem.BusinessAddressStreet.Trim() + " " + myItem.BusinessAddressCity + " " + myItem.BusinessAddressState + " " + myItem.BusinessAddressPostalCode; if (myItem.BusinessAddress == myItem.MailingAddress) { defaultAddress = tempLoc + "_Business"; } else { scratchPadAddress += "adr." + tempLoc + "_Business~"; } } if (myItem.OtherAddress != null && myItem.OtherAddress.Trim().Length > 0) { tempLoc = myItem.OtherAddressStreet.Trim() + " " + myItem.OtherAddressCity + " " + myItem.OtherAddressState + " " + myItem.OtherAddressPostalCode; if (myItem.OtherAddress == myItem.MailingAddress) { defaultAddress = tempLoc + "_Other"; } else { scratchPadAddress += "adr." + tempLoc + "_Other~"; } } } webBrowser1.Navigate("http://local.live.com/default.aspx?style=r&where1=" + defaultAddress + "&sp=" + scratchPadAddress); }
public static void SetCompanies(Outlook.ContactItem source, Contact destination) { destination.Organizations.Clear(); if (!string.IsNullOrEmpty(source.Companies)) { //Companies are expected to be in form of "[Company]; [Company]". string[] companiesRaw = source.Companies.Split(';'); foreach (string companyRaw in companiesRaw) { Organization company = new Organization(); company.Name = (destination.Organizations.Count == 0) ? source.CompanyName : null; company.Title = (destination.Organizations.Count == 0)? source.JobTitle : null; company.Department = (destination.Organizations.Count == 0) ? source.Department : null; company.Primary = destination.Organizations.Count == 0; company.Rel = ContactsRelationships.IsWork; destination.Organizations.Add(company); } } if (destination.Organizations.Count == 0 && (!string.IsNullOrEmpty(source.CompanyName) || !string.IsNullOrEmpty(source.JobTitle) || !string.IsNullOrEmpty(source.Department))) { Organization company = new Organization(); company.Name = source.CompanyName; company.Title = source.JobTitle; company.Department = source.Department; company.Primary = true; company.Rel = ContactsRelationships.IsWork; destination.Organizations.Add(company); } }
/// <summary> /// EventHandler for ItemAdd Event of InboxFolder /// </summary> /// <param name="Item">The Item wich was added to InboxFolder</param> private void Items_ItemAdd(object Item) { if (MutexManager.InFullSync()) { return; } try { // Check the ItemType, could be a MeetingAccept or something else if (Item is Ol.ContactItem) { // Cast to ContactItem Object Ol.ContactItem contact = (Ol.ContactItem)Item; if (MutexManager.IsBlocked(contact)) { logger.Debug("Removing contact " + OutlookAdapter.ContactItemDisplay(contact) + " from mutex file"); MutexManager.ClearBlockedContact(contact); return; } logger.Info("Adding " + OutlookAdapter.ContactItemDisplay(contact)); // Do something with Item GoogleAdapter ga = new GoogleAdapter(Config.Username, Config.Password, logger); MutexManager.AddToBlockedContacts(contact); ga.CreateContactFromOutlookAsync(contact); // Release COM Object contact = null; } } catch (System.Exception ex) { logger.Error(ex.Message); logger.Debug(ex.StackTrace.ToString()); MessageBox.Show(ex.Message); } }
public static Image GetOutlookPhoto(Outlook.ContactItem outlookContact) { if (!HasPhoto(outlookContact)) { return(null); } try { foreach (Outlook.Attachment a in outlookContact.Attachments) { // CH Fixed this to Contains, due to outlook picture that looks like "ContactPicture_138382.jpg" if (a.DisplayName.ToUpper().Contains("CONTACTPICTURE") || a.DisplayName.ToUpper().Contains("CONTACTPHOTO")) { //TODO: Check why always the first added picture is returned //If you add another picture, still the old picture is saved to tempPhotoPath a.SaveAsFile(tempPhotoPath); using (Image img = Image.FromFile(tempPhotoPath)) { return(new Bitmap(img)); } } } return(null); } catch { // There's an error here... If Outlook says it has a contact photo, and we can't get it, Something's broken. return(null); } }
public static DateTime?GetOutlookLastSync(Synchronizer sync, Outlook.ContactItem outlookContact) { DateTime?result = null; Outlook.UserProperties userProperties = outlookContact.UserProperties; try { Outlook.UserProperty prop = userProperties[sync.OutlookPropertyNameSynced]; if (prop != null) { try { result = (DateTime)prop.Value; } finally { Marshal.ReleaseComObject(prop); } } } finally { Marshal.ReleaseComObject(userProperties); } return(result); }
public static string GetOutlookGoogleContactId(Synchronizer sync, Outlook.ContactItem outlookContact) { string id = null; Outlook.UserProperties userProperties = outlookContact.UserProperties; try { Outlook.UserProperty idProp = userProperties[sync.OutlookPropertyNameId]; if (idProp != null) { try { id = (string)idProp.Value; if (id == null) { throw new Exception(); } } finally { Marshal.ReleaseComObject(idProp); } } } finally { Marshal.ReleaseComObject(userProperties); } return(id); }
private bool IsContactExist(string FullName) { bool found = false; Outlook.NameSpace outlookNameSpace = this.Application.GetNamespace("MAPI"); Outlook.MAPIFolder contactsFolder = outlookNameSpace.GetDefaultFolder( Microsoft.Office.Interop.Outlook. OlDefaultFolders.olFolderContacts); Outlook.Items contactItems = contactsFolder.Items; try { Outlook.ContactItem contact = (Outlook.ContactItem)contactItems. Find(String.Format("[FullName]='{0}'", FullName)); if (contact != null) { found = true; } else { found = false; } } catch (Exception ex) { throw ex; } return(found); }
public static void SetOutlookLastSync(Synchronizer sync, Outlook.ContactItem outlookContact) { //save sync datetime Outlook.UserProperties userProperties = outlookContact.UserProperties; try { Outlook.UserProperty prop = userProperties[sync.OutlookPropertyNameSynced]; if (prop == null) { prop = userProperties.Add(sync.OutlookPropertyNameSynced, Outlook.OlUserPropertyType.olDateTime, true); } try { prop.Value = DateTime.Now; } finally { Marshal.ReleaseComObject(prop); } } finally { Marshal.ReleaseComObject(userProperties); } }
private OutLook.ContactItem FindContactEmailByID(String ID) { OutLook.NameSpace outlookNameSpace = OutLookApp.GetNamespace("MAPI"); if (folder == null) { folder = OutLookApp.Session.GetDefaultFolder( OutLook.OlDefaultFolders.olFolderContacts).Folders[ tbContactsFolder.Text] as OutLook.Folder; } OutLook.Items contactItems = folder.Items; try { OutLook.ContactItem contact = (OutLook.ContactItem)contactItems. Find(String.Format("[Organizational ID]='{0}'", ID)); if (contact != null) { return(contact); } else { } } catch (Exception ex) { } return(null); }
public static void SetOutlookGoogleContactId(Syncronizer sync, Outlook.ContactItem outlookContact, ContactEntry googleContact) { if (googleContact.Id.Uri == null) { throw new NullReferenceException("GoogleContact must have a valid Id"); } //check if outlook contact aready has google id property. Outlook.UserProperty prop = outlookContact.UserProperties[sync.OutlookPropertyNameId]; if (prop == null) { prop = outlookContact.UserProperties.Add(sync.OutlookPropertyNameId, Outlook.OlUserPropertyType.olText, null, null); } prop.Value = googleContact.Id.Uri.Content; //save last google's updated date as property /*prop = outlookContact.UserProperties[OutlookPropertyNameUpdated]; * if (prop == null) * prop = outlookContact.UserProperties.Add(OutlookPropertyNameUpdated, Outlook.OlUserPropertyType.olDateTime, null, null); * prop.Value = googleContact.Updated;*/ //save sync datetime prop = outlookContact.UserProperties[sync.OutlookPropertyNameSynced]; if (prop == null) { prop = outlookContact.UserProperties.Add(sync.OutlookPropertyNameSynced, Outlook.OlUserPropertyType.olDateTime, null, null); } prop.Value = DateTime.Now; }
public OutlookContactItem(Microsoft.Office.Interop.Outlook.ContactItem baseItem) { _baseContact = baseItem; SyncValuesFromBase(); }
public OContact(Outlook.Application app, IContact other) { _item = (Outlook.ContactItem)app.CreateItem(Outlook.OlItemType.olContactItem); MergeFrom(other); }
public OContact(Outlook.Application app, string name) { _item = (Outlook.ContactItem)app.CreateItem(Outlook.OlItemType.olContactItem); _item.FullName = name; }
public OContact(Outlook.ContactItem item) { _item = item; }
public ContactPreview(Outlook.ContactItem _outlookContact) { InitializeComponent(); outlookContact = _outlookContact; InitializeFields(); }