internal void WritePartWithHeaders(MimePart part, bool copyBoundaryToSkeleton) { this.StartPart(null, copyBoundaryToSkeleton); if ((this.flags & MimeStreamWriter.Flags.SkipHeaders) == MimeStreamWriter.Flags.SkipHeaders && this.mimeTextStream != null) { this.mimeTextStream.StartWriting(); this.flags &= (MimeStreamWriter.Flags)(-2); if (this.mimeWriter == null) { goto IL_98; } using (Stream rawContentWriteStream = this.mimeWriter.GetRawContentWriteStream()) { using (Stream rawContentReadStream = part.GetRawContentReadStream()) { Util.StreamHandler.CopyStreamData(rawContentReadStream, rawContentWriteStream); } goto IL_98; } } if (this.mimeWriter != null) { using (Stream rawContentWriteStream2 = this.mimeWriter.GetRawContentWriteStream()) { part.WriteTo(rawContentWriteStream2); } } IL_98: this.EndPart(copyBoundaryToSkeleton); }
internal static bool TryGetFileNameFromBinHex(MimePart mimePart, ref string fileName) { string text; using (Stream rawContentReadStream = mimePart.GetRawContentReadStream()) { try { BinHexDecoder binHexDecoder = new BinHexDecoder(); using (EncoderStream encoderStream = new EncoderStream(rawContentReadStream, binHexDecoder, EncoderStreamAccess.Read)) { byte[] array = new byte[256]; encoderStream.Read(array, 0, array.Length); text = binHexDecoder.MacBinaryHeader.FileName; } } catch (ByteEncoderException) { text = null; } } if (string.IsNullOrEmpty(text)) { return(false); } fileName = text; return(true); }
private static bool TryGetFileNameFromUuencode(MimePart part, ref string fileName) { byte[] array = new byte[1050]; int inputSize; using (Stream rawContentReadStream = part.GetRawContentReadStream()) { inputSize = rawContentReadStream.Read(array, 0, array.Length); } bool result; using (UUDecoder uudecoder = new UUDecoder()) { byte[] array2 = new byte[1050]; int num; int num2; bool flag; uudecoder.Convert(array, 0, inputSize, array2, 0, array2.Length, false, out num, out num2, out flag); string fileName2 = uudecoder.FileName; if (string.IsNullOrEmpty(fileName2)) { result = false; } else { fileName = fileName2; result = true; } } return(result); }
internal static Stream GetContentReadStream(MimePart part) { Stream rawContentReadStream; if (!part.TryGetContentReadStream(out rawContentReadStream)) { rawContentReadStream = part.GetRawContentReadStream(); } return(rawContentReadStream); }
public override bool FilterPartBody(MimePart part, Stream stream) { if (this.embedded) { EightToSevenBitConverter.Convert(part.GetRawContentReadStream(), stream); this.embedded = false; return(true); } if (this.encoder != null) { using (Stream stream2 = new EncoderStream(part.GetRawContentReadStream(), this.encoder, EncoderStreamAccess.Read)) { DataStorage.CopyStreamToStream(stream2, stream, long.MaxValue, ref this.scratchBuffer); this.encoder = null; return(true); } return(false); } return(false); }
internal static void CalculateBodySize(MimePartInfo partInfo, MimePart part) { if (partInfo.IsBodySizeComputed) { return; } using (Stream stream = new MimeStreamWriter.MimeBodySizeCounter(null, partInfo)) { using (Stream rawContentReadStream = part.GetRawContentReadStream()) { Util.StreamHandler.CopyStreamData(rawContentReadStream, stream); } } }