/// <summary> /// Set up the recipients of the appointment represented by this `olItem` from this `crmItem`. /// </summary> /// <param name="olItem">The Outlook item to update.</param> /// <param name="crmItem">The CRM item to use as source.</param> /// <param name="sMeetingID"></param> /// <param name="crmModule">The module the CRM item is in.</param> protected void SetOutlookRecipientsFromCRM(Outlook.AppointmentItem olItem, EntryValue crmItem, string sMeetingID, string crmModule) { this.LogItemAction(olItem, "SetRecipients"); try { int iCount = olItem.Recipients.Count; for (int iItr = 1; iItr <= iCount; iItr++) { olItem.Recipients.Remove(1); } if (crmItem != null && crmItem.relationships != null && crmItem.relationships.link_list != null) { foreach (var relationship in crmItem.relationships.link_list) { foreach (LinkRecord record in relationship.records) { string email1 = record.data.GetValueAsString("email1"); string phone_work = record.data.GetValueAsString("phone_work"); string identifier = (crmModule == MeetingsSynchroniser.CrmModule) || string.IsNullOrWhiteSpace(phone_work) ? email1 : $"{email1} : {phone_work}"; if (!String.IsNullOrWhiteSpace(identifier)) { if (olItem.GetOrganizer().GetSmtpAddress() != email1) { olItem.EnsureRecipient(email1, identifier); } } } } } } finally { this.SaveItem(olItem); } }
/// <summary> /// Ensure that this appointment item has a recipient with this smtpAddress; if it has not, /// add one to it. /// </summary> /// <param name="olItem">The appointment.</param> /// <param name="smtpAddress">The SMTP address.</param> public static void EnsureRecipient(this Outlook.AppointmentItem olItem, string smtpAddress) { olItem.EnsureRecipient(smtpAddress, smtpAddress); }