public override MimePartHeaders GetHeaders() { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetHeaders.1"); this.CheckDisposed(null); MimePartHeaders headers; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetHeaders.1)"); MimePartInfo mimeSkeleton = this.GetMimeSkeleton(); if (mimeSkeleton.Headers == null || mimeSkeleton.Headers.Count == 0) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter((MimeStreamWriter.Flags) 6, this.itemEncodingOptions)) { this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders | ItemToMimeConverter.MimeFlags.SkipContent); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.1)"); headers = mimeSkeleton.Headers; } } return(headers); }
public override MimePartInfo GetMimeStructure() { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetMimeStructure."); this.CheckDisposed(null); MimePartInfo result; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetMimeStructure)"); MimePartInfo mimeSkeleton = this.GetMimeSkeleton(); if (mimeSkeleton.IsBodySizeComputed) { this.GetHeaders(); } else { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter((MimeStreamWriter.Flags) 6, this.itemEncodingOptions)) { this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetMimeStructure)"); result = mimeSkeleton; } } return(result); }
private bool GetText(Stream outStream, bool isSinglePartOnly) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetText.1"); this.CheckDisposed(null); if (outStream == null) { throw new ArgumentNullException("outStream"); } using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetText.1)"); MimePartInfo mimeSkeleton = this.GetMimeSkeleton(); if (isSinglePartOnly && mimeSkeleton.IsMultipart) { return(false); } using (Stream stream = new StreamWrapper(outStream, false)) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, this.itemEncodingOptions, (MimeStreamWriter.Flags) 3)) { this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.SkipMessageHeaders); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetText.1)"); } } return(true); }
public override void GetBody(Stream outStream) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetBody.1"); this.CheckDisposed(null); if (outStream == null) { throw new ArgumentNullException("outStream"); } using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetBody.1)"); MimePartInfo mimeSkeleton = this.GetMimeSkeleton(); using (Stream stream = new StreamWrapper(outStream, false)) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, this.itemEncodingOptions, (MimeStreamWriter.Flags) 6)) { this.WriteMimePart(this.mimeProvider, mimeStreamWriter, this.options, mimeSkeleton, ItemToMimeConverter.MimeFlags.WriteMessageHeaders); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetBody.1)"); } } }
public override bool GetBody(Stream outStream, uint[] indices) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetBody.2"); this.CheckDisposed(null); bool result; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetBody.2)"); bool flag = false; if (indices == null || indices.Length == 0) { this.GetBody(outStream); flag = true; } else { List <IDisposable> disposeList = null; MimePartInfo partInfo = null; Item item = null; try { EncodingOptions encodingOptions; IImapMimeProvider subpartConverter = this.GetSubpartConverter(indices, out partInfo, out item, out encodingOptions, out disposeList); if (subpartConverter != null) { using (Stream stream = new StreamWrapper(outStream, false)) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, encodingOptions, (MimeStreamWriter.Flags) 3)) { this.WriteMimePart(subpartConverter, mimeStreamWriter, this.options, partInfo, ItemToMimeConverter.MimeFlags.SkipMessageHeaders); } } flag = true; } } finally { this.DisposeAll(disposeList); } } if (!flag) { int num = indices.Length - 1; if (indices[num] == 1U) { uint[] array = new uint[num]; Array.Copy(indices, array, num); flag = this.GetText(outStream, array, true); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetBody.2)"); result = flag; } } return(result); }
private bool GetText(Stream outStream, uint[] indices, bool isSinglePartOnly) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetText.2"); this.CheckDisposed(null); bool result; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetText.2)"); bool flag = false; if (indices == null || indices.Length == 0) { flag = this.GetText(outStream, isSinglePartOnly); } else { List <IDisposable> disposeList = null; MimePartInfo mimePartInfo = null; Item item = null; EncodingOptions encodingOptions = null; try { IImapMimeProvider imapMimeProvider = this.GetSubpartConverter(indices, out mimePartInfo, out item, out encodingOptions, out disposeList); if (imapMimeProvider != null) { imapMimeProvider = this.GetAttachedItemConverter(ref mimePartInfo, ref item, ref encodingOptions, disposeList); if (imapMimeProvider != null && (!mimePartInfo.IsMultipart || !isSinglePartOnly)) { using (Stream stream = new StreamWrapper(outStream, false)) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(stream, encodingOptions, MimeStreamWriter.Flags.SkipHeaders)) { this.WriteMimePart(imapMimeProvider, mimeStreamWriter, this.options, mimePartInfo, ItemToMimeConverter.MimeFlags.SkipMessageHeaders); } } flag = true; } } } finally { this.DisposeAll(disposeList); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetText.2)"); result = flag; } } return(result); }
public override MimePartHeaders GetMime(uint[] indices) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetMime."); this.CheckDisposed(null); if (indices == null || indices.Length == 0) { return(null); } MimePartHeaders result; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetMime)"); MimePartHeaders mimePartHeaders = null; MimePartInfo mimePartInfo = this.FindMimePart(indices); if (mimePartInfo != null && mimePartInfo.Headers != null && mimePartInfo.Headers.Count != 0) { mimePartHeaders = mimePartInfo.Headers; } else { mimePartInfo = this.GetMimeSkeleton(); List <IDisposable> disposeList = null; Item item = null; EncodingOptions encodingOptions = null; try { IImapMimeProvider subpartConverter = this.GetSubpartConverter(indices, out mimePartInfo, out item, out encodingOptions, out disposeList); if (subpartConverter != null) { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter(MimeStreamWriter.Flags.ProduceMimeStructure, encodingOptions)) { this.WriteMimePart(subpartConverter, mimeStreamWriter, this.options, mimePartInfo, ItemToMimeConverter.MimeFlags.SkipContent); } mimePartHeaders = mimePartInfo.Headers; } } finally { this.DisposeAll(disposeList); } } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetMime)"); result = mimePartHeaders; } } return(result); }
private void WriteAttachments() { if (this.item.AttachmentCollection != null) { int num = 0; this.item.CoreItem.OpenAttachmentCollection(); foreach (AttachmentHandle handle in this.item.CoreItem.AttachmentCollection) { using (Attachment attachment = this.item.AttachmentCollection.Open(handle, InternalSchema.ContentConversionProperties)) { if (this.options.FilterAttachmentHandler == null || this.options.FilterAttachmentHandler(this.item, attachment)) { using (StorageGlobals.SetTraceContext(attachment)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting attachment (OutboundMsgStorage.WriteAttachments)"); this.WriteAttachment(attachment, num++); StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing attachment (OutboundMsgStorage.WriteAttachments)"); } } } } } }
private void WriteAttachments() { if (this.item.AttachmentCollection != null) { int num = 0; long num2 = 0L; this.item.CoreItem.OpenAttachmentCollection(); foreach (AttachmentHandle handle in this.item.CoreItem.AttachmentCollection) { num++; using (Attachment attachment = this.item.AttachmentCollection.Open(handle, InternalSchema.ContentConversionProperties)) { using (StorageGlobals.SetTraceContext(attachment)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting attachment (ItemToTnefConverter.WriteAttachments)"); num2 += this.WriteAttachment(this.item, attachment); StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing attachment (ItemToTnefConverter.WriteAttachments)"); } } } this.conversionResult.AttachmentCount = num; this.conversionResult.AccumulatedAttachmentSize = num2; } }
public override MimePartHeaders GetHeaders(uint[] indices) { StorageGlobals.ContextTraceInformation(ExTraceGlobals.CcOutboundMimeTracer, "ImapItemConverter::GetHeaders.2"); this.CheckDisposed(null); MimePartHeaders result; using (StorageGlobals.SetTraceContext(this.options)) { using (StorageGlobals.SetTraceContext(this.itemIn)) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Starting item (ImapItemConverter.GetHeaders.2)"); if (indices == null || indices.Length == 0) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); result = this.GetHeaders(); } else { MimePartInfo mimePartInfo = this.FindMimePart(indices); if (mimePartInfo != null) { if (mimePartInfo.ContentType != MimePartContentType.ItemAttachment) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); return(null); } mimePartInfo = mimePartInfo.AttachedItemStructure; if (mimePartInfo != null && mimePartInfo.Headers != null && mimePartInfo.Headers.Count != 0) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); return(mimePartInfo.Headers); } } mimePartInfo = this.GetMimeSkeleton(); List <IDisposable> disposeList = null; Item item = null; try { EncodingOptions encodingOptions; if (this.GetSubpartConverter(indices, out mimePartInfo, out item, out encodingOptions, out disposeList) == null) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); result = null; } else { IImapMimeProvider attachedItemConverter = this.GetAttachedItemConverter(ref mimePartInfo, ref item, ref encodingOptions, disposeList); if (attachedItemConverter == null) { StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); result = null; } else { using (MimeStreamWriter mimeStreamWriter = new MimeStreamWriter((MimeStreamWriter.Flags) 6, encodingOptions)) { this.WriteMimePart(attachedItemConverter, mimeStreamWriter, this.options, mimePartInfo, ItemToMimeConverter.MimeFlags.WriteMessageHeaders | ItemToMimeConverter.MimeFlags.SkipContent); } StorageGlobals.ContextTracePfd(ExTraceGlobals.CcPFDTracer, "Finishing item (ImapItemConverter.GetHeaders.2)"); result = mimePartInfo.Headers; } } } finally { this.DisposeAll(disposeList); } } } } return(result); }