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();
                            }
                        }
                    }
                }
            }
        }