// Token: 0x06001C02 RID: 7170 RVA: 0x0006D978 File Offset: 0x0006BB78
        private static void CreateFailureMessages(UserContext userContext, ExchangePrincipal exchangePrincipal, Dictionary <string, IList <IUserSharingResult> > failedResultsDictionary, List <string> noProviderResources, List <string> resourceList, List <string> largeDLsList)
        {
            string text = null;
            List <AttachmentFile> list;

            if (noProviderResources != null)
            {
                list = UpdateAttachmentPermissions.GetAttachmentFiles(noProviderResources);
                text = AttachmentMessageBodyGenerator.GenerateBodyForAttachmentNotFound(list);
                UpdateAttachmentPermissions.CreateOneFailureMessage(userContext, exchangePrincipal, text, list);
            }
            if (failedResultsDictionary != null && failedResultsDictionary.Count > 0)
            {
                list = new List <AttachmentFile>();
                List <string>     list2 = new List <string>();
                IRecipientSession adrecipientSession = CallContext.Current.ADRecipientSessionContext.GetADRecipientSession();
                foreach (string text2 in failedResultsDictionary.Keys)
                {
                    AttachmentFile item = new AttachmentFile(UpdateAttachmentPermissions.GetFileNameFromLocation(text2), HttpUtility.UrlDecode(text2));
                    list.Add(item);
                    foreach (IUserSharingResult userSharingResult in failedResultsDictionary[text2])
                    {
                        string text3 = userSharingResult.User;
                        if (text3 != null && !text3.Contains("@"))
                        {
                            text3 = UpdateAttachmentPermissions.ConvertBetweenADRecipientProperties(adrecipientSession, text3, ADRecipientSchema.ExternalDirectoryObjectId, ADRecipientSchema.PrimarySmtpAddress);
                        }
                        if (text3 != null)
                        {
                            list2.Add(text3);
                        }
                    }
                }
                text = AttachmentMessageBodyGenerator.GenerateBodyForSetWrongPermission(list, list2);
                UpdateAttachmentPermissions.CreateOneFailureMessage(userContext, exchangePrincipal, text, list);
            }
            list = UpdateAttachmentPermissions.GetAttachmentFiles(resourceList);
            if (largeDLsList != null && largeDLsList.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (string value in largeDLsList)
                {
                    if (stringBuilder.Length > 0)
                    {
                        stringBuilder.Append(Strings.DistributionListNameSeperator);
                    }
                    stringBuilder.Append(value);
                }
                text = AttachmentMessageBodyGenerator.GenerateBodyForSentToTooLargeDL(list, stringBuilder.ToString());
                UpdateAttachmentPermissions.CreateOneFailureMessage(userContext, exchangePrincipal, text, list);
                return;
            }
            if (text == null)
            {
                text = AttachmentMessageBodyGenerator.GenerateBodyForCatchAll(list);
                UpdateAttachmentPermissions.CreateOneFailureMessage(userContext, exchangePrincipal, text, list);
            }
        }
 // Token: 0x06001BFF RID: 7167 RVA: 0x0006D71C File Offset: 0x0006B91C
 private static void SendInvitationMessage(UserContext userContext, ExchangePrincipal exchangePrincipal, string user, string location, string invitationLink)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             if (string.IsNullOrEmpty(user))
             {
                 throw new ArgumentNullException("user", "User name cannot be null when sending invite!");
             }
             if (string.IsNullOrEmpty(invitationLink))
             {
                 throw new ArgumentNullException("invitationLink", "InvitationLink cannot be null when sending invite!");
             }
             if (string.IsNullOrEmpty(location))
             {
                 throw new ArgumentNullException("location", "Document location cannot be null when sending invite!");
             }
             try
             {
                 string fileNameFromLocation = UpdateAttachmentPermissions.GetFileNameFromLocation(location);
                 userContext.LockAndReconnectMailboxSession();
                 MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox));
                 messageItem.From        = new Participant(exchangePrincipal);
                 messageItem.Sender      = messageItem.From;
                 messageItem.Subject     = string.Format(Strings.GuestSharingInvitationSubject, exchangePrincipal.MailboxInfo.DisplayName, fileNameFromLocation);
                 messageItem.IsDraft     = false;
                 messageItem.IsRead      = false;
                 messageItem.Recipients.Add(new Participant(user, user, "SMTP"));
                 string bodyContent = AttachmentMessageBodyGenerator.GenerateBodyForInvitation(fileNameFromLocation, invitationLink);
                 UpdateAttachmentPermissions.SetItemBody(messageItem, BodyFormat.TextHtml, bodyContent);
                 messageItem.SendWithoutSavingMessage();
             }
             catch (InvalidRecipientsException ex2)
             {
                 ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "[UpdateAttachmentPermissions : SendInvitationMessage] Exception happened when trying to send the invitation message : {0}", ex2.StackTrace);
             }
             finally
             {
                 if (userContext.MailboxSessionLockedByCurrentThread())
                 {
                     userContext.UnlockAndDisconnectMailboxSession();
                 }
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "[UpdateAttachmentPermissions : SendInvitationMessage] Exception happened when trying to send the invitation message : {0}", ex.StackTrace);
     }
 }
        public static string GenerateBodyForAttachmentNotFound(List <AttachmentFile> attachmentFiles)
        {
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();
            string        headingText;

            if (attachmentFiles.Count == 1)
            {
                headingText = Strings.OneAttachmentNotFoundInbox;
                list.Add(Strings.OneAttachmentNotFoundSmallText);
                list2.Add(Strings.OneAttachmentNotFoundLargeText);
            }
            else
            {
                headingText = Strings.AttachmentsNotFoundInbox;
                list.Add(Strings.AttachmentsNotFoundSmallText);
                list2.Add(Strings.AttachmentsNotFoundLargeText);
            }
            return(AttachmentMessageBodyGenerator.GenerateNDRBody(headingText, list, attachmentFiles, false, null, list2));
        }
        public static string GenerateBodyForCatchAll(List <AttachmentFile> attachmentFiles)
        {
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();
            string        headingText;

            if (attachmentFiles.Count == 1)
            {
                headingText = Strings.OneAttachmentCatchAllInbox;
                list.Add(Strings.OneAttachmentCatchAllSmallText);
                string arg = string.Format("<a href=\"{0}\" target=\"_blank\" style=\"text-decoration: none;color:#0072C6\">{1}</a>", attachmentFiles[0].FileURL, attachmentFiles[0].FileName);
                list2.Add(string.Format(Strings.OneAttachmentCatchAllLargeText, arg));
            }
            else
            {
                headingText = Strings.AttachmentsCatchAllInbox;
                list.Add(Strings.AttachmentsCatchAllSmallText);
                list2.Add(Strings.AttachmentsCatchAllLargeText);
            }
            return(AttachmentMessageBodyGenerator.GenerateNDRBody(headingText, list, attachmentFiles, true, null, list2));
        }
        public static string GenerateBodyForSetWrongPermission(List <AttachmentFile> attachmentFiles, List <string> recipients)
        {
            List <string> list  = new List <string>();
            List <string> list2 = new List <string>();
            string        headingText;

            if (attachmentFiles.Count == 1)
            {
                headingText = Strings.OneAttachmentSetWrongPermissionInbox;
                list.Add(Strings.OneAttachmentSetWrongPermissionSmallText);
                list2.Add(Strings.OneAttachmentSetWrongPermissionLargeText1);
                list2.Add(Strings.OneAttachmentSetWrongPermissionLargeText2);
                list2.Add(Strings.OneAttachmentSetWrongPermissionLargeText3);
            }
            else
            {
                headingText = Strings.AttachmentsSetWrongPermissionInbox;
                list.Add(Strings.AttachmentsSetWrongPermissionSmallText);
                list2.Add(Strings.OneAttachmentSetWrongPermissionLargeText1);
                list2.Add(Strings.AttachmentsSetWrongPermissionLargeText2);
                list2.Add(Strings.AttachmentsSetWrongPermissionLargeText3);
            }
            return(AttachmentMessageBodyGenerator.GenerateNDRBody(headingText, list, attachmentFiles, true, recipients, list2));
        }