Exemplo n.º 1
0
        private MimeEntityReturnCode ProcessDelimitedBody(
            RxMailMessage message,
            string BoundaryStart,
            string parentBoundaryStart,
            string parentBoundaryEnd)
        {
            string response;

            if (BoundaryStart.Trim() == parentBoundaryStart.Trim())
            {
                //Mime entity boundaries have to be unique
                callGetEmailWarning("new boundary same as parent boundary: '{0}'", parentBoundaryStart);
                //empty this message
                while (readMultiLine(out response))
                {
                }
                return MimeEntityReturnCode.problem;
            }

            //
            MimeEntityReturnCode ReturnCode;
            do
            {
                //empty StringBuilder
                MimeEntitySB.Length = 0;
                RxMailMessage ChildPart = message.CreateChildEntity();

                //recursively call MIME part processing
                ReturnCode = ProcessMimeEntity(ChildPart, BoundaryStart);

                if (ReturnCode == MimeEntityReturnCode.problem)
                {
                    //it seems the received email doesn't follow the MIME specification. Stop here
                    return MimeEntityReturnCode.problem;
                }

                //add the newly found child MIME part to the parent
                AddChildPartsToParent(ChildPart, message);
            } while (ReturnCode != MimeEntityReturnCode.parentBoundaryEndFound);

            //disregard all future lines until parent boundary is found or end of complete message
            MimeEntityReturnCode boundaryMimeReturnCode;
            bool hasParentBoundary = parentBoundaryStart.Length > 0;
            while (readMultiLine(out response))
            {
                if (hasParentBoundary &&
                    parentBoundaryFound(response, parentBoundaryStart, parentBoundaryEnd, out boundaryMimeReturnCode))
                {
                    return boundaryMimeReturnCode;
                }
            }

            return MimeEntityReturnCode.bodyComplete;
        }