private string GetEcpUrl()
 {
     if (AsyncOperationNotificationEmail.ecpUrl == null)
     {
         Uri uri = null;
         IExchangePrincipal mailbox = this.provider.Mailbox;
         try
         {
             if (AsyncOperationNotificationEmail.discoveryEcpExternalUrl == null)
             {
                 AsyncOperationNotificationEmail.discoveryEcpExternalUrl = (Func <IExchangePrincipal, Uri>)Delegate.CreateDelegate(typeof(Func <IExchangePrincipal, Uri>), Type.GetType("Microsoft.Exchange.Data.ApplicationLogic.Cafe.FrontEndLocator, Microsoft.Exchange.Data.ApplicationLogic").GetMethod("GetFrontEndEcpUrl", BindingFlags.Static | BindingFlags.Public, null, new Type[]
                 {
                     typeof(IExchangePrincipal)
                 }, null));
             }
             uri = AsyncOperationNotificationEmail.discoveryEcpExternalUrl(mailbox);
         }
         catch (Exception)
         {
         }
         if (uri != null && uri.IsAbsoluteUri)
         {
             AsyncOperationNotificationEmail.ecpUrl = uri.AbsoluteUri;
         }
     }
     return(AsyncOperationNotificationEmail.ecpUrl ?? string.Empty);
 }
 public void SendNotificationEmail(AsyncOperationNotification notification, bool forceSendCreatedMail, IEnumerable <LocalizedString> report, bool throwOnError)
 {
     if (AsyncOperationNotificationDataProvider.IsAsyncNotificationDisabled())
     {
         ExTraceGlobals.StorageTracer.TraceWarning(0L, "DisableAsyncNotification is set in registry, no notification email will be sent.");
         return;
     }
     if (notification == null)
     {
         throw new ArgumentNullException("notification");
     }
     try
     {
         AsyncOperationNotificationEmail asyncOperationNotificationEmail = new AsyncOperationNotificationEmail(this, notification, forceSendCreatedMail);
         string alternativeId;
         if (AsyncOperationNotificationDataProvider.SettingsObjectIdentityMap.TryGetValue(notification.Type, out alternativeId))
         {
             AsyncOperationNotification asyncOperationNotification = this.FindByAlternativeId <AsyncOperationNotification>(alternativeId);
             if (asyncOperationNotification != null)
             {
                 asyncOperationNotificationEmail.AppendRecipients(asyncOperationNotification.NotificationEmails);
             }
         }
         if (asyncOperationNotificationEmail.ToRecipients.Count <EmailAddress>() > 0)
         {
             if (report != null)
             {
                 StringBuilder stringBuilder = new StringBuilder();
                 foreach (LocalizedString value in report)
                 {
                     stringBuilder.AppendLine(value);
                 }
                 string s     = stringBuilder.ToString();
                 byte[] bytes = Encoding.Default.GetBytes(s);
                 asyncOperationNotificationEmail.Attachments.AddFileAttachment("Report.txt", bytes);
             }
             int  num = 0;
             bool flag;
             do
             {
                 flag = asyncOperationNotificationEmail.Send();
                 num++;
             }while (!flag && base.CanRetry && num < 3);
             if (forceSendCreatedMail && (notification.Status == AsyncOperationStatus.Completed || notification.Status == AsyncOperationStatus.Failed))
             {
                 this.SendNotificationEmail(notification, false, report, throwOnError);
             }
         }
     }
     catch (Exception ex)
     {
         string printableId = AsyncOperationNotificationDataProvider.GetPrintableId(base.Mailbox.MailboxInfo.OrganizationId, notification.AlternativeId);
         ExTraceGlobals.StorageTracer.TraceError <string, string>(0L, "AsyncOperationNotificationDataProvider::SendNotificationEmail failed: {0}, message: {1}", printableId, ex.Message);
         StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_ErrorSendNotificationEmail, printableId, new object[]
         {
             printableId,
             ex
         });
         if (throwOnError)
         {
             throw;
         }
     }
 }