Exemplo n.º 1
0
        private static void CopyProtectableData(Body sourceBody, AttachmentCollection sourceAttachmentCollection, MessageItem targetItem)
        {
            if (sourceBody.IsBodyDefined)
            {
                using (Stream stream = sourceBody.OpenReadStream(new BodyReadConfiguration(sourceBody.Format, sourceBody.RawCharset.Name)))
                {
                    using (Stream stream2 = targetItem.Body.OpenWriteStream(new BodyWriteConfiguration(sourceBody.Format, sourceBody.RawCharset)))
                    {
                        Util.StreamHandler.CopyStreamData(stream, stream2);
                    }
                    goto IL_6D;
                }
            }
            targetItem.DeleteProperties(Body.BodyProps);
IL_6D:
            targetItem.AttachmentCollection.RemoveAll();
            foreach (AttachmentHandle handle in sourceAttachmentCollection)
            {
                using (Attachment attachment = sourceAttachmentCollection.Open(handle))
                {
                    using (Attachment attachment2 = attachment.CreateCopy(targetItem.AttachmentCollection, new BodyFormat?(targetItem.Body.Format)))
                    {
                        attachment2.Save();
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal override Attachment CreateCopy(AttachmentCollection collection, BodyFormat?targetBodyFormat)
        {
            bool flag = targetBodyFormat != null && targetBodyFormat != BodyFormat.ApplicationRtf;

            if (flag)
            {
                return(this.ConvertToImageAttachment(collection.CoreAttachmentCollection, ImageFormat.Jpeg));
            }
            return((Attachment)Attachment.CreateCopy(this, collection, new AttachmentType?(AttachmentType.Ole)));
        }
Exemplo n.º 3
0
        protected void CopyAttachments(BodyConversionCallbacks callbacks, AttachmentCollection sourceCollection, AttachmentCollection targetCollection, bool copyInlinesOnly, bool targetIsPlainText, InboundConversionOptions optionsForSmime)
        {
            ReadOnlyCollection <AttachmentLink> readOnlyCollection = null;
            bool flag = true;

            if (callbacks.HtmlCallback != null && callbacks.HtmlCallback.AttachmentListInitialized)
            {
                readOnlyCollection = callbacks.HtmlCallback.AttachmentLinks;
                flag = (flag && callbacks.HtmlCallback.ClearInlineOnUnmarkedAttachments);
            }
            if (callbacks.RtfCallback != null && callbacks.RtfCallback.AttachmentListInitialized)
            {
                readOnlyCollection = callbacks.RtfCallback.AttachmentLinks;
                flag = (flag && callbacks.RtfCallback.ClearInlineOnUnmarkedAttachments);
            }
            if (readOnlyCollection == null)
            {
                if (copyInlinesOnly)
                {
                    return;
                }
                using (IEnumerator <AttachmentHandle> enumerator = sourceCollection.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AttachmentHandle handle = enumerator.Current;
                        using (Attachment attachment = sourceCollection.Open(handle, null))
                        {
                            if (!attachment.IsCalendarException)
                            {
                                using (Attachment attachment2 = attachment.CreateCopy(targetCollection, new BodyFormat?(this.parameters.TargetFormat)))
                                {
                                    attachment2.IsInline = false;
                                    attachment2.Save();
                                }
                            }
                        }
                    }
                    return;
                }
            }
            foreach (AttachmentLink attachmentLink in readOnlyCollection)
            {
                if (!copyInlinesOnly || attachmentLink.IsInline(flag))
                {
                    using (Attachment attachment3 = sourceCollection.Open(attachmentLink.AttachmentId, null))
                    {
                        if (!copyInlinesOnly || !(attachment3 is ReferenceAttachment))
                        {
                            using (Attachment attachment4 = attachment3.CreateCopy(targetCollection, new BodyFormat?(this.parameters.TargetFormat)))
                            {
                                attachmentLink.MakeAttachmentChanges(attachment4, flag);
                                if (targetIsPlainText)
                                {
                                    attachment4.IsInline = false;
                                }
                                attachment4.Save();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 internal virtual Attachment CreateCopy(AttachmentCollection collection, BodyFormat?targetBodyFormat)
 {
     return((Attachment)Attachment.CreateCopy(this, collection, new AttachmentType?(this.AttachmentType)));
 }