// 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);
     }
 }
 // Token: 0x06001C00 RID: 7168 RVA: 0x0006D8C0 File Offset: 0x0006BAC0
 private static void CreateOneFailureMessage(UserContext userContext, ExchangePrincipal exchangePrincipal, string body, List <AttachmentFile> attachmentFiles)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             try
             {
                 userContext.LockAndReconnectMailboxSession();
                 MessageItem messageItem = MessageItem.Create(userContext.MailboxSession, userContext.MailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox));
                 messageItem.From        = new Participant("Microsoft Outlook", "*****@*****.**", "SMTP");
                 messageItem.Sender      = messageItem.From;
                 messageItem.IsDraft     = false;
                 messageItem.IsRead      = false;
                 messageItem.Recipients.Add(new Participant(exchangePrincipal), RecipientItemType.To);
                 UpdateAttachmentPermissions.SetItemBody(messageItem, BodyFormat.TextHtml, body);
                 if (attachmentFiles.Count == 1)
                 {
                     messageItem.Subject = string.Format(Strings.OneAttachmentSharingFailureSubject, attachmentFiles[0].FileName);
                 }
                 else
                 {
                     messageItem.Subject = Strings.AttachmentSharingFailureSubject;
                 }
                 messageItem.Save(SaveMode.NoConflictResolutionForceSave);
                 messageItem[ItemSchema.ReceivedTime] = ExDateTime.Now;
                 messageItem.Save(SaveMode.ResolveConflicts);
             }
             finally
             {
                 if (userContext.MailboxSessionLockedByCurrentThread())
                 {
                     userContext.UnlockAndDisconnectMailboxSession();
                 }
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "[UpdateAttachmentPermissions : CreateMessage] Exception happened when trying to send message : {0}", ex.StackTrace);
     }
 }
 // Token: 0x06001BF7 RID: 7159 RVA: 0x0006D004 File Offset: 0x0006B204
 private static void ProcessUpdatePermissionsAsyncResult(UserContext userContext, UpdatePermissionsAsyncResult result, List <string> resourceList, List <string> largeDLsList)
 {
     ExTraceGlobals.AttachmentHandlingTracer.TraceDebug(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Method start");
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
         {
             Dictionary <string, IList <IUserSharingResult> > dictionary = new Dictionary <string, IList <IUserSharingResult> >();
             foreach (string text in result.ResultsDictionary.Keys)
             {
                 IEnumerable <IUserSharingResult> enumerable = result.ResultsDictionary[text];
                 foreach (IUserSharingResult userSharingResult in enumerable)
                 {
                     if (!userSharingResult.Status)
                     {
                         if (!dictionary.ContainsKey(text))
                         {
                             dictionary.Add(text, new List <IUserSharingResult>());
                         }
                         dictionary[text].Add(userSharingResult);
                     }
                     if (!string.IsNullOrEmpty(userSharingResult.InvitationLink) && !string.IsNullOrEmpty(userSharingResult.User))
                     {
                         ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Send invitiation for user : {0}", userSharingResult.User);
                         UpdateAttachmentPermissions.SendInvitationMessage(userContext, userContext.ExchangePrincipal, userSharingResult.User, HttpUtility.UrlDecode(text), userSharingResult.InvitationLink);
                     }
                 }
             }
             if (dictionary.Count > 0 || (largeDLsList != null && largeDLsList.Count > 0))
             {
                 ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <int>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] There were {0} number of failures when setting perms", dictionary.Count);
                 UpdateAttachmentPermissions.CreateFailureMessages(userContext, userContext.ExchangePrincipal, dictionary, null, resourceList, largeDLsList);
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "[UpdateAttachmentPermissions : ProcessUpdatePermissionsAsyncResult] Exception happened when processing results : {0}", ex.StackTrace);
     }
 }
 // Token: 0x06001BF5 RID: 7157 RVA: 0x0006CC0C File Offset: 0x0006AE0C
 internal static void UpdateAttachmentPermissionsAsync(AttachmentDataProvider attachmentDataProvider, string[] userIds, AttachmentPermissionAssignment[] permissionAssignments, UserContext userContext, List <string> resourceList, List <string> largeDLsList)
 {
     try
     {
         OwaDiagnostics.SendWatsonReportsForGrayExceptions(async delegate()
         {
             UpdatePermissionsAsyncResult updatePermissionsAsyncResult = await attachmentDataProvider.UpdateDocumentPermissionsAsync(userIds, permissionAssignments, default(CancellationToken)).ConfigureAwait(false);
             if (updatePermissionsAsyncResult.ResultCode != AttachmentResultCode.Success)
             {
                 UpdateAttachmentPermissions.CreateFailureMessages(userContext, userContext.ExchangePrincipal, null, null, resourceList, null);
             }
             else
             {
                 UpdateAttachmentPermissions.ProcessUpdatePermissionsAsyncResult(userContext, updatePermissionsAsyncResult, resourceList, largeDLsList);
             }
         });
     }
     catch (GrayException ex)
     {
         ExTraceGlobals.AttachmentHandlingTracer.TraceError <string>(0L, "UpdateAttachmentPermissions.UpdateAttachmentPermissionsAsync Exception while trying to update permissions async : {0}", ex.StackTrace);
     }
 }