From e98e3a5de807e5f5c7a3bbc9e158371b94a7d764 Mon Sep 17 00:00:00 2001 From: Paul Woolcock <11843015+phw198@users.noreply.github.com> Date: Sun, 29 Nov 2020 15:02:07 +0000 Subject: [PATCH] Handle failure to get primary SMTP from Exchange recipient. #1126 --- .../OutlookOgcs/OutlookNew.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookNew.cs b/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookNew.cs index 7a551d76..86f5d4b6 100644 --- a/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookNew.cs +++ b/src/OutlookGoogleCalendarSync/OutlookOgcs/OutlookNew.cs @@ -517,9 +517,14 @@ public String GetRecipientEmail(Recipient recipient) { ExchangeUser eu = null; try { eu = addressEntry.GetExchangeUser(); - if (eu != null && eu.PrimarySmtpAddress != null) - retEmail = eu.PrimarySmtpAddress; - else { + if (eu != null) { + try { + retEmail = eu.PrimarySmtpAddress; + } catch (System.Exception ex) { + OGCSexception.Analyse("Could not access Exchange users's primary SMTP.", OGCSexception.LogAsFail(ex)); + } + } + if (eu == null || string.IsNullOrEmpty(retEmail)) { log.Warn("Exchange does not have an email for recipient: " + recipient.Name); Microsoft.Office.Interop.Outlook.PropertyAccessor pa = null; try { @@ -800,7 +805,7 @@ private TimeZoneInfo getWindowsTimezoneFromDescription(String tzDescription) { if (tzi != null) return tzi; //Finally, fuzzy logic - log.Warn("Could not find timezone ID based on given description. Attempting some fuzzy logic..."); + log.Warn("Could not find timezone ID based on given description, '" + tzDescription + "'. Attempting some fuzzy logic..."); if (tzDescription.StartsWith("(GMT")) { log.Fine("Replace GMT with UTC"); String modTzDescription = tzDescription.Replace("(GMT", "(UTC");