// Token: 0x06000034 RID: 52 RVA: 0x00003938 File Offset: 0x00001B38 private static bool TryGetCommentAttachment(MessageItem messageItem, out StreamAttachment targetAttachment) { targetAttachment = null; AttachmentCollection attachmentCollection = messageItem.AttachmentCollection; foreach (AttachmentHandle handle in attachmentCollection) { Attachment attachment = null; try { attachment = attachmentCollection.Open(handle); if ("DecisionComments.txt".Equals(attachment.FileName, StringComparison.OrdinalIgnoreCase)) { targetAttachment = (attachment as StreamAttachment); if (targetAttachment != null) { attachment = null; return(true); } ModeratedDLApplication.diag.TraceError <Attachment>(0L, "Found attachment with the correct name, but it's not a stream: {0}", attachment); } } finally { if (attachment != null) { attachment.Dispose(); attachment = null; } } } return(false); }
private void InitializeLoadedItemPart(IItem item, IStorePropertyBag propertyBag, BodyFragmentInfo bodyFragmentInfo, bool didLoadSucceed, long bytesLoaded, AttachmentCollection attachmentCollection) { this.bodyFragmentInfo = bodyFragmentInfo; if (this.bodyFragmentInfo == null) { base.UniqueFragmentInfo = (base.DisclaimerFragmentInfo = FragmentInfo.Empty); } this.didLoadSucceed = didLoadSucceed; if (this.didLoadSucceed) { this.bytesLoaded = bytesLoaded; } base.ItemId = item.Id.ObjectId; base.Subject = (item.TryGetProperty(ItemSchema.Subject) as string); if (attachmentCollection != null) { foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle, null)) { base.RawAttachments.Add(new AttachmentInfo(item.Id.ObjectId, attachment)); } } } IMessageItem messageItem = item as IMessageItem; if (messageItem != null) { if (messageItem.Sender != null) { this.displayNameToParticipant[messageItem.Sender.DisplayName] = messageItem.Sender; } if (messageItem.From != null) { this.displayNameToParticipant[messageItem.From.DisplayName] = messageItem.From; } foreach (Recipient recipient in messageItem.Recipients) { recipient.Participant.Submitted = recipient.Submitted; this.displayNameToParticipant[recipient.Participant.DisplayName] = recipient.Participant; base.Recipients.Add(recipient.RecipientItemType, new IParticipant[] { recipient.Participant }); } foreach (Participant participant in messageItem.ReplyTo) { this.displayNameToParticipant[participant.DisplayName] = participant; } } if (propertyBag != null) { base.StorePropertyBag = propertyBag; } }
public void FromLeftToRightType(TStorageItem left, TItem right) { List <IAttachment> list = new List <IAttachment>(); AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(left); IList <AttachmentHandle> handles = attachmentCollection.GetHandles(); foreach (AttachmentHandle handle in handles) { using (Attachment attachment = attachmentCollection.Open(handle)) { IAttachment item = this.AttachmentConverter.Convert(attachment); list.Add(item); } } right.Attachments = list; }
public IEnumerable <IAttachment> GetAllAttachments() { using (IItem parentItem = this.BindToParentItem()) { AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(parentItem); foreach (AttachmentHandle attachmentHandle in attachmentCollection.GetHandles()) { using (Attachment attachment = attachmentCollection.Open(attachmentHandle)) { StorageTranslator <IAttachment, IAttachment> translator = this.GetAttachmentTranslator(attachment.AttachmentType, false); IAttachment resultAttachment = translator.ConvertToEntity(attachment); yield return(resultAttachment); } } } yield break; }
// Token: 0x06002C61 RID: 11361 RVA: 0x000F7264 File Offset: 0x000F5464 private Stream GetContactPictureStream(Item item, string attId, out string contentType) { contentType = string.Empty; if (item == null) { return(new MemoryStream()); } if (string.IsNullOrEmpty(attId)) { attId = RenderingUtilities.GetContactPictureAttachmentId(item); } if (string.IsNullOrEmpty(attId)) { return(new MemoryStream()); } AttachmentId id = item.CreateAttachmentId(attId); AttachmentCollection attachmentCollection = Utilities.GetAttachmentCollection(item, true, base.UserContext); Stream result; using (StreamAttachment streamAttachment = attachmentCollection.Open(id) as StreamAttachment) { if (streamAttachment == null) { throw new OwaInvalidRequestException("Attachment is not a stream attachment"); } AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, base.UserContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { result = new MemoryStream(); } else { contentType = AttachmentEventHandler.GetContentType(streamAttachment.FileName); if (contentType.Length == 0) { ExTraceGlobals.ContactsTracer.TraceDebug <string>((long)this.GetHashCode(), "Cannot determine image type for file: {0}", streamAttachment.FileName); result = new MemoryStream(); } else { result = streamAttachment.GetContentStream(); } } } return(result); }
// Token: 0x0600003E RID: 62 RVA: 0x00004434 File Offset: 0x00002634 private void AttachOriginalMessageToNotification(MessageItem initiationMessage, MessageItem notificationMessage, out string originalSenderDisplayname) { originalSenderDisplayname = string.Empty; if (string.IsNullOrEmpty(this.defaultAcceptedDomain)) { ModeratedDLApplication.diag.TraceDebug((long)this.GetHashCode(), "Cannot attach original message to notification without domain for content conversion."); return; } AttachmentCollection attachmentCollection = initiationMessage.AttachmentCollection; foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle)) { if ("OriginalMessage".Equals(attachment.FileName, StringComparison.OrdinalIgnoreCase)) { StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null) { using (Stream contentStream = streamAttachment.GetContentStream(PropertyOpenMode.ReadOnly)) { using (ItemAttachment itemAttachment = (ItemAttachment)notificationMessage.AttachmentCollection.Create(AttachmentType.EmbeddedMessage)) { using (Item item = itemAttachment.GetItem()) { InboundConversionOptions options = new InboundConversionOptions(this.defaultAcceptedDomain); ItemConversion.ConvertAnyMimeToItem(item, contentStream, options); item[MessageItemSchema.Flags] = MessageFlags.None; originalSenderDisplayname = (item.TryGetProperty(MessageItemSchema.SenderDisplayName) as string); item.Save(SaveMode.NoConflictResolution); itemAttachment[AttachmentSchema.DisplayName] = initiationMessage.Subject; itemAttachment.Save(); } } } } break; } } } }
internal long WriteToStream(ConfigurationContextBase configurationContext, Stream outputStream, OutboundConversionOptions outboundConversionOptions, BlockStatus blockStatus, long outputStreamPosition, IList <string> fileNames, AttachmentCollection attachmentCollection) { this.headerOffset = outputStreamPosition; Stream stream = null; uint num = 0U; using (Attachment attachment = attachmentCollection.Open(this.attachmentId)) { try { if (attachment.AttachmentType == AttachmentType.EmbeddedMessage) { this.fileNames = fileNames; stream = this.GetItemAttachmentStream(attachment, outboundConversionOptions); } else { this.fileNames = null; stream = ZipEntryAttachment.GetStreamAttachmentStream(attachment); } if (stream.Length > 0L) { Stream stream2; if (this.doNeedToFilterHtml) { if (this.CompressionMethod != 0) { stream2 = AttachmentUtilities.GetFilteredStream(configurationContext, stream, attachment.TextCharset, blockStatus); } else { stream2 = this.GetFilteredResponseStream(configurationContext, stream, attachment.TextCharset, blockStatus); } } else { stream2 = this.GetUnfilteredStream(stream); } if (stream2 != stream) { stream.Close(); stream = stream2; } } if (this.CompressionMethod == 0) { if (!stream.CanSeek) { throw new ArgumentException("stream", "Stream is required to support Seek operations, and does not"); } this.attachmentSize = stream.Length; } this.WriteZipFileHeader(stream, outputStream); this.WriteFileData(stream, outputStream, blockStatus); if (this.CompressionMethod != 0) { num = this.WriteZipFileDescriptor(outputStream); } } finally { if (stream != null) { stream.Close(); stream = null; } } } return((long)((ulong)(this.headerBytesWritten + this.attachmentBytesWritten + num))); }
// Token: 0x0600060B RID: 1547 RVA: 0x0002E8F8 File Offset: 0x0002CAF8 private bool CompareAttachments(AttachmentCollection originalAttachments, AttachmentCollection currentAttachments) { if (originalAttachments != null && currentAttachments != null) { if (originalAttachments.Count != currentAttachments.Count) { return(false); } IList <AttachmentHandle> handles = originalAttachments.GetHandles(); IList <AttachmentHandle> handles2 = currentAttachments.GetHandles(); for (int i = 0; i < handles.Count; i++) { using (Attachment originalAttachment = originalAttachments.Open(handles[i])) { using (Attachment currentAttachment = currentAttachments.Open(handles2[i])) { originalAttachment.Load(); currentAttachment.Load(); if (originalAttachment.AttachmentType != currentAttachment.AttachmentType) { return(false); } if (originalAttachment.DisplayName != currentAttachment.DisplayName) { return(false); } if (originalAttachment.FileExtension != currentAttachment.FileExtension) { return(false); } if (originalAttachment.FileName != currentAttachment.FileName) { return(false); } if (originalAttachment.Size != currentAttachment.Size) { return(false); } if (originalAttachment is StreamAttachmentBase && currentAttachment is StreamAttachmentBase) { if (!this.CompareStreams(() => ((StreamAttachmentBase)originalAttachment).TryGetContentStream(PropertyOpenMode.ReadOnly), () => ((StreamAttachmentBase)currentAttachment).TryGetContentStream(PropertyOpenMode.ReadOnly))) { return(false); } } else if (originalAttachment is ItemAttachment) { using (Item itemAsReadOnly = ((ItemAttachment)originalAttachment).GetItemAsReadOnly(HoldCleanupEnforcer.PropertyColumns)) { using (Item itemAsReadOnly2 = ((ItemAttachment)currentAttachment).GetItemAsReadOnly(HoldCleanupEnforcer.PropertyColumns)) { if (!this.AreItemsLegallyEqual(itemAsReadOnly.ClassName, itemAsReadOnly, itemAsReadOnly2)) { return(false); } } } } } } } } else if (originalAttachments != null || currentAttachments != null) { return(false); } return(true); }
// Token: 0x060013E0 RID: 5088 RVA: 0x00072734 File Offset: 0x00070934 public IEnumerator <Attachment12Data> GetEnumerator() { Item message = base.XsoItem as Item; Attachment12Data attachmentData = null; if (message == null) { throw new UnexpectedTypeException("Item", base.XsoItem); } MeetingRequest meetingRequest = base.XsoItem as MeetingRequest; if (meetingRequest == null || !meetingRequest.IsDelegated()) { string idbase = null; if (this.idmapping != null) { idbase = this.idmapping[MailboxSyncItemId.CreateForNewItem(message.Id.ObjectId)]; } if (idbase == null) { idbase = message.Id.ObjectId.ToBase64String(); } if (message is MessageItem && ((MessageItem)message).IsRestricted && !BodyConversionUtilities.IsMessageRestrictedAndDecoded(message) && !BodyConversionUtilities.IsIRMFailedToDecode(message)) { object prop = message.TryGetProperty(MessageItemSchema.DRMLicense); if (prop is byte[][]) { byte[][] license = (byte[][])prop; if (license.Length > 0) { attachmentData = new Attachment14Data(); attachmentData.DisplayName = "message.rpmsg.license"; attachmentData.Method = 1; attachmentData.EstimatedDataSize = (long)license[0].Length; attachmentData.IsInline = false; attachmentData.FileReference = HttpUtility.UrlEncode(idbase + ":DRMLicense"); AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "Add DRM license as attachment, message is MessageItem {0}, message.IsRestricted {1}, IsDecoded {2}, FailedToDecode {3}", new object[] { message is MessageItem, ((MessageItem)message).IsRestricted, BodyConversionUtilities.IsMessageRestrictedAndDecoded(message), BodyConversionUtilities.IsIRMFailedToDecode(message) }); yield return(attachmentData); } else { AirSyncDiagnostics.TraceDebug <int>(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. Length = {0}", license.Length); } } else { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.XsoTracer, this, "The license property on the DRM message is incorrect. prop = {0}", new object[] { prop }); } } AttachmentCollection attachmentCollection = null; if (BodyConversionUtilities.IsMessageRestrictedAndDecoded(message)) { attachmentCollection = ((RightsManagedMessageItem)message).ProtectedAttachmentCollection; } else { if (BodyConversionUtilities.IsIRMFailedToDecode(message)) { goto IL_3FC; } attachmentCollection = message.AttachmentCollection; } int index = -1; foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle)) { if (BodyUtility.IsClearSigned(message) && (string.Equals(attachment.FileName, "smime.p7m", StringComparison.OrdinalIgnoreCase) || string.Equals(attachment.ContentType, "multipart/signed", StringComparison.OrdinalIgnoreCase))) { continue; } attachmentData = this.GetAttachmentData(message, attachment, idbase, ref index); } if (attachmentData != null) { yield return(attachmentData); } } } IL_3FC: yield break; }
// Token: 0x0600010E RID: 270 RVA: 0x00004984 File Offset: 0x00002B84 public Stream GetAllAttachmentsAsZipStream(AttachmentHandler.IAttachmentRetriever attachmentRetriever) { ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>((long)this.GetHashCode(), "AttachmentHandler.GetAttachmentStream: Getting attachment stream for id={0}", this.id); if (string.IsNullOrEmpty(this.id)) { ExTraceGlobals.AttachmentHandlingTracer.TraceDebug((long)this.GetHashCode(), "Item id is empty or null. returning null stream."); throw new FaultException("Id cannot be null or empty."); } Item rootItem = attachmentRetriever.RootItem; if (rootItem is ReportMessage || ObjectClass.IsSmsMessage(rootItem.ClassName)) { return(null); } Stream stream = null; Stream result; try { AttachmentHandler.IAttachmentPolicyChecker attachmentPolicyChecker = AttachmentPolicyChecker.CreateInstance(this.configurationContext.AttachmentPolicy); AttachmentCollection attachmentCollection = IrmUtils.GetAttachmentCollection(rootItem); BlockStatus itemBlockStatus = AttachmentHandler.GetItemBlockStatus(rootItem); string subject = AttachmentHandler.GetSubject(rootItem); ZipFileAttachments zipFileAttachments = new ZipFileAttachments(itemBlockStatus, subject); foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle)) { if (attachment is OleAttachment || attachment.IsInline || attachment is ReferenceAttachment) { ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>((long)this.GetHashCode(), "Attachment is inline, an ole image, or a reference attachment. Do not add to zip file. id is {0}", attachment.Id.ToString()); } else { AttachmentPolicyLevel policy = attachmentPolicyChecker.GetPolicy(attachment, this.webOperationContext.IsPublicLogon); if (this.IsBlocked(policy)) { ExTraceGlobals.AttachmentHandlingTracer.TraceDebug <string>((long)this.GetHashCode(), "Attachment is blocked. Do not add to zip file. id is {0}", attachment.Id.ToString()); } else { zipFileAttachments.AddAttachmentToZip(attachment, policy, this.configurationContext); } } } } if (zipFileAttachments.Count == 0) { ExTraceGlobals.AttachmentHandlingTracer.TraceDebug((long)this.GetHashCode(), "AttachmentHandler.GetAllAttachmentsAsZipStream: No attachments returned for item"); result = null; } else { IRecipientSession adrecipientSession = rootItem.Session.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid); OutboundConversionOptions outboundConversionOptions = new OutboundConversionOptions(this.callContext.DefaultDomain.DomainName.Domain); outboundConversionOptions.ClearCategories = false; outboundConversionOptions.UserADSession = adrecipientSession; outboundConversionOptions.LoadPerOrganizationCharsetDetectionOptions(adrecipientSession.SessionSettings.CurrentOrganizationId); stream = zipFileAttachments.WriteArchive(this.configurationContext, this.webOperationContext, outboundConversionOptions, attachmentCollection); stream.Seek(0L, SeekOrigin.Begin); result = stream; } } catch (Exception ex) { if (stream != null) { stream.Dispose(); } string formatString = string.Empty; if (ex is ExchangeDataException) { formatString = "Fail to sanitize HTML getting attachment. id is {0}, Exception: {1}"; } else if (ex is StoragePermanentException) { formatString = "StoragePermanentException when getting attachment. id is {0}, Exception: {1}"; } else { if (!(ex is StorageTransientException)) { throw; } formatString = "StorageTransientException when getting attachment. id is {0}, Exception: {1}"; } ExTraceGlobals.AttachmentHandlingTracer.TraceError <string, Exception>((long)this.GetHashCode(), formatString, this.id, ex); throw new CannotOpenFileAttachmentException(ex); } return(result); }
private static string GetAttachmentByUrlCompName(MailboxSession mailboxSession, string attachmentId, Stream outStream, int offset, int count, Unlimited <ByteQuantifiedSize> maxAttachmentSize, out int total) { attachmentId = "/" + attachmentId; int andCheckLastSlashLocation = AttachmentHelper.GetAndCheckLastSlashLocation(attachmentId, attachmentId); string text = attachmentId.Substring(0, andCheckLastSlashLocation); string text2 = attachmentId.Substring(andCheckLastSlashLocation + 1); andCheckLastSlashLocation = AttachmentHelper.GetAndCheckLastSlashLocation(text, attachmentId); string propertyValue = text.Substring(0, andCheckLastSlashLocation); StoreId storeId = null; QueryFilter seekFilter = new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.UrlName, propertyValue); using (Folder folder = Folder.Bind(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Root))) { using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, AirSyncUtility.XsoFilters.GetHierarchyFilter, null, AttachmentHelper.folderPropertyIds)) { if (queryResult.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { object[][] rows = queryResult.GetRows(1); storeId = (rows[0][0] as StoreId); } } } if (storeId == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentId)); } AirSyncDiagnostics.TraceDebug <StoreId>(ExTraceGlobals.RequestsTracer, null, "Getting attachment with parentStoreId {0}.", storeId); StoreId storeId2 = null; seekFilter = new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.UrlName, text); using (Folder folder2 = Folder.Bind(mailboxSession, storeId)) { using (QueryResult queryResult2 = folder2.ItemQuery(ItemQueryType.None, null, null, AttachmentHelper.itemPropertyIds)) { if (queryResult2.SeekToCondition(SeekReference.OriginBeginning, seekFilter)) { object[][] rows2 = queryResult2.GetRows(1); storeId2 = (rows2[0][0] as StoreId); } } } if (storeId2 == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentId)); } AirSyncDiagnostics.TraceDebug <StoreId>(ExTraceGlobals.RequestsTracer, null, "Getting attachment with itemStoreId {0}.", storeId2); PropertyTagPropertyDefinition propertyTagPropertyDefinition = PropertyTagPropertyDefinition.CreateCustom("UrlCompName", 284360734U); string attachmentItself; using (Item item = Item.Bind(mailboxSession, storeId2)) { AttachmentCollection attachmentCollection = item.AttachmentCollection; attachmentCollection.Load(new PropertyDefinition[] { propertyTagPropertyDefinition }); AttachmentId attachmentId2 = null; foreach (AttachmentHandle handle in attachmentCollection) { using (Attachment attachment = attachmentCollection.Open(handle)) { if (text2.Equals((string)attachment[propertyTagPropertyDefinition], StringComparison.Ordinal)) { attachmentId2 = attachment.Id; break; } } } if (attachmentId2 == null) { foreach (AttachmentHandle handle2 in attachmentCollection) { using (Attachment attachment2 = attachmentCollection.Open(handle2)) { string str = (string)attachment2[propertyTagPropertyDefinition]; if (text2.EndsWith("_" + str, StringComparison.Ordinal)) { attachmentId2 = attachment2.Id; break; } } } } if (attachmentId2 == null) { throw new ObjectNotFoundException(ServerStrings.MapiCannotOpenAttachmentId(attachmentId)); } AirSyncDiagnostics.TraceDebug <AttachmentId>(ExTraceGlobals.RequestsTracer, null, "Getting attachment with attachment ID {0}.", attachmentId2); using (Attachment attachment3 = attachmentCollection.Open(attachmentId2)) { if (!maxAttachmentSize.IsUnlimited && attachment3.Size > (long)maxAttachmentSize.Value.ToBytes()) { throw new DataTooLargeException(StatusCode.AttachmentIsTooLarge); } attachmentItself = AttachmentHelper.GetAttachmentItself(attachment3, outStream, offset, count, out total); } } return(attachmentItself); }
// Token: 0x06001E1F RID: 7711 RVA: 0x000AE510 File Offset: 0x000AC710 public static void RenderAttachments(TextWriter output, AttachmentWellType wellType, ArrayList attachmentList, UserContext userContext, bool isConversationAndIrmCopyRestricted) { if (output == null) { throw new ArgumentNullException("output"); } if (userContext == null) { throw new ArgumentNullException("userContext"); } if (attachmentList == null || attachmentList.Count <= 0) { return; } bool flag = true; Utilities.GetEmbeddedDepth(HttpContext.Current.Request); ArrayList previousAttachmentDisplayNames = new ArrayList(); Item item = null; try { foreach (object obj in attachmentList) { AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj; AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentWellInfo); if (AttachmentUtility.AttachmentLinkFlags.Skip != (AttachmentUtility.AttachmentLinkFlags.Skip & attachmentLinkFlag)) { ItemAttachment itemAttachment = null; Item item2 = null; try { if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage) { if (attachmentWellInfo.MessageId != null) { if (item != null) { StoreObjectId storeObjectId = StoreId.GetStoreObjectId(item.Id); if (!storeObjectId.Equals(attachmentWellInfo.MessageId.StoreObjectId)) { item.Dispose(); item = null; } } if (item == null) { item = Utilities.GetItem <Item>(userContext, attachmentWellInfo.MessageId, false, null); } AttachmentCollection attachmentCollection = item.AttachmentCollection; if (userContext.IsIrmEnabled && Utilities.IrmDecryptIfRestricted(item, userContext)) { attachmentCollection = ((RightsManagedMessageItem)item).ProtectedAttachmentCollection; } itemAttachment = (ItemAttachment)attachmentCollection.Open(attachmentWellInfo.AttachmentId); } else { itemAttachment = (ItemAttachment)attachmentWellInfo.OpenAttachment(); } item2 = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[] { TaskSchema.TaskType }); } if (!flag) { output.Write("; "); } else { flag = false; } output.Write("<span id=spnAtmt tabindex=\"-1\" "); if (wellType == AttachmentWellType.ReadOnly && AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink != (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag)) { output.Write("class=\"dsbl\""); } if (attachmentWellInfo.MessageId != null) { output.Write(" _sId=\""); Utilities.SanitizeHtmlEncode(attachmentWellInfo.MessageId.ToString(), output); output.Write("\""); } string text; if (item2 != null) { text = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item2); } else { text = attachmentWellInfo.AttachmentName; } output.Write(" _attid=\""); output.Write(Utilities.SanitizeHtmlEncode(attachmentWellInfo.AttachmentId.ToBase64String())); output.Write("\" _level="); output.Write((int)attachmentWellInfo.AttachmentLevel); output.Write(" _attname=\""); output.Write(Utilities.SanitizeHtmlEncode(text)); output.Write("\" _attsize=\""); output.Write(attachmentWellInfo.Size); output.Write("\" _fIsItem=\""); output.Write(item2 != null); output.Write("\""); if (attachmentWellInfo.AttachmentType != AttachmentType.EmbeddedMessage) { output.Write(" _protectable=\""); bool flag2 = false; try { flag2 = ProtectorsManager.Instance.IsProtectorRegistered(attachmentWellInfo.FileExtension); } catch (AttachmentProtectionException) { } output.Write(flag2 ? "1" : "0"); output.Write("\""); } if (item2 != null) { Task task = item2 as Task; if ((task != null && !TaskUtilities.IsAssignedTask(task)) || item2 is Contact || item2 is DistributionList) { output.Write(" _qs=\"ae=PreFormAction&a=OpenEmbedded&t="); } else { output.Write(" _qs=\"ae=Item&t="); } Utilities.SanitizeHtmlEncode(Utilities.UrlEncode(item2.ClassName), output); if (task != null && TaskUtilities.IsAssignedTask(task)) { output.Write("&s=Assigned"); } output.Write("\""); } output.Write(">"); bool flag3 = AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink == (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag); if (flag3) { string text2 = null; if (item2 != null || attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow) { text2 = "3"; } else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave) { text2 = "2"; } if (text2 != null) { output.Write("<a class=\"lnkClickAtmt\" id=\"lnkAtmt\" _fAllwCM=\"1\" href=\"#\" target=_blank "); Utilities.RenderScriptHandler(output, "onclick", string.Concat(new string[] { "atLnk(event, ", text2, ", ", isConversationAndIrmCopyRestricted ? "1" : "0", ");" })); output.Write(" title=\""); Utilities.SanitizeHtmlEncode(text, output); if (text2 == "3" & item2 != null) { output.Write("\" oncontextmenu=\"return false;"); } output.Write("\">"); } } if (item2 != null) { SmallIconManager.RenderItemIcon(output, userContext, item2.ClassName, false, "sI", new string[0]); } else { string fileExtension = string.Empty; if (attachmentWellInfo.FileExtension != null) { fileExtension = attachmentWellInfo.FileExtension; } SmallIconManager.RenderFileIcon(output, userContext, fileExtension, "sI", new string[0]); } if (item2 != null) { Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, true), output); } else { Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, false), output); long size = attachmentWellInfo.Size; if (size > 0L) { output.Write(userContext.DirectionMark); output.Write(" "); output.Write(SanitizedHtmlString.FromStringId(6409762)); Utilities.RenderSizeWithUnits(output, size, true); output.Write(userContext.DirectionMark); output.Write(SanitizedHtmlString.FromStringId(-1023695022)); } } if (flag3) { output.Write("</a>"); } if (item2 == null && AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink == (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink & attachmentLinkFlag)) { AttachmentWell.RenderWebReadyLink(output, userContext); } if (wellType == AttachmentWellType.ReadWrite) { output.Write("<span class=\"delLnk\">"); userContext.RenderThemeImage(output, ThemeFileId.DeleteSmall, null, new object[] { "id=delImg" }); output.Write("</span>"); } output.Write("</span>"); } catch (ObjectNotFoundException) { } catch (StorageTransientException) { } finally { if (item2 != null) { item2.Dispose(); item2 = null; } if (itemAttachment != null) { itemAttachment.Dispose(); itemAttachment = null; } } } } } finally { if (item != null) { item.Dispose(); item = null; } } }