Exemplo n.º 1
0
        }                     //EF

        /// <summary> Constructor.</summary>
        /// <param name="email"> The email. </param>
        public MIMEpart(MIMEemail email)
        {
            this._headers                = new List <MIMEheader>();
            this.ContainedParts          = new List <MIMEpart>();
            this.IsMIMEpart              = false;
            this.ContentTransferEncoding = ContentTransferEncodingType.Bit7;
            this._email = email;
            //_errorLogElement = errorLogElement;
        }
Exemplo n.º 2
0
        /// <summary> Parse mim epart.</summary>
        /// <param name="mimEemail">  The mim eemail. </param>
        /// <param name="dataStream"> The data stream. </param>
        /// <param name="parentPart"> The parent part. </param>
        /// <param name="finalPart">  [out] The final part. </param>
        /// <returns> A MIMEpart.</returns>
        private MIMEpart ParseMIMEpart(MIMEemail mimEemail, LineReader dataStream, MIMEpart parentPart, out bool finalPart)
        {
            var currentPart = new MIMEpart(mimEemail);

            if (parentPart != null)
            {
                currentPart.Encoding = parentPart.Encoding;
            }

            finalPart = false;

            var boundaryFound = false;

            // parse IMF headers
            this.ParseHeaders(dataStream, currentPart, parentPart, Encoding.ASCII, out boundaryFound);

            if (boundaryFound) // boundary was found => empty content
            {
                currentPart.HasEmptyContent = true;
                return(currentPart);
            }

            // if current part is also multipart parse all sub parts
            if (currentPart.IsMultiPart)
            {
                var isFinalPart = false;
                currentPart.RawContent = this.ReadData(dataStream, currentPart.PartBoundary, currentPart.ContentBoundary, currentPart.Encoding,
                                                       out isFinalPart);

                while (!isFinalPart)
                {
                    currentPart.AddPart(this.ParseMIMEpart(mimEemail, dataStream, currentPart, out isFinalPart));
                }
            }
            else
            {
                // this is not multipart part => read part content :

                if (parentPart == null || parentPart.ContentBoundary == null)
                {
                    // boundary was not set or specified - read till end of IMF data :
                    finalPart = true;
                    //currentPart.RawContent = dataStream.ReadToEnd();

                    //currentPart.RawContent = currentPart.encoding.GetString(dataStream.ReadBytes(int.MaxValue));
                    // currentPart.RawContent = dataStream.ReadToEnd();

                    currentPart.RawContent = currentPart.Encoding.GetString(dataStream.ReadBytes((int)(dataStream.BaseStream.Length - dataStream.BaseStream.Position)));
                }
                else
                {
                    bool isDataFinalPart;
                    currentPart.RawContent = currentPart.RawContent = this.ReadData(dataStream, parentPart.PartBoundary, parentPart.ContentBoundary, currentPart.Encoding,
                                                                                    out isDataFinalPart);

                    if (isDataFinalPart)
                    {
                        finalPart = true;
                    }
                }
            }



            if (currentPart.RawContent == null)
            {
                currentPart.HasEmptyContent = true;
            }

            return(currentPart);
        }