private ImapWebResponse GetPartialFetchResponse(ImapSequenceSet requestedUidSet, string section, ImapPartialRange? partial)
        {
            var responseStream = new ImapWebClientFetchMessageBodyStream(Session,
                                                                   KeepAlive,
                                                                   FetchPeek,
                                                                   requestedUidSet,
                                                                   section,
                                                                   partial,
                                                                   FetchBlockSize,
                                                                   ReadWriteTimeout);

              IImapMessageAttribute discard;
              var response = new ImapWebResponse(responseStream.Prepare(GetFetchDataItem(), out discard));

              if (response.Result.Failed)
            return response;

              response.SetResponseStream(responseStream,
                                 responseStream.Length,
                                 true);

              return response;
        }
        private ImapWebResponse GetFullFetchResponse(ImapSequenceSet requestedUidSet)
        {
            var responseStream = new ImapWebClientFetchMessageBodyStream(Session,
                                                                   KeepAlive,
                                                                   FetchPeek,
                                                                   requestedUidSet,
                                                                   FetchBlockSize,
                                                                   ReadWriteTimeout);

              IImapMessageAttribute messageAttr;
              var response = new ImapWebResponse(responseStream.Prepare(GetFetchDataItem(), out messageAttr));

              if (response.Result.Failed)
            return response;

              response.MessageAttributes = new[] {messageAttr};
              response.SetResponseStream(responseStream,
                                 responseStream.Length,
                                 true);

              if (messageAttr.BodyStructure != null)
            response.SetContentType((string)messageAttr.BodyStructure.MediaType);

              return response;
        }
        private ImapWebResponse GetAppendResponse()
        {
            if (beginAppendAsyncResult == null)
            throw new InvalidOperationException("GetRequestStream not called");

              try {
            appendMessageBodyStream.UpdateLength();

            ImapAppendedUidSet appendedUid;

            var response = new ImapWebResponse(Session.EndAppend(beginAppendAsyncResult, out appendedUid));

            if (response.Result.Succeeded) {
              // set empty stream; WebClient.Upload*() methods call WebResponse.GetResponseStream
              response.SetResponseStream(Stream.Null, 0L, false);

              if (appendedUid != null) {
            var builder = new ImapUriBuilder(RequestUri);

            builder.UidValidity = appendedUid.UidValidity;
            builder.Uid = appendedUid.ToNumber(); // if appendedUid.IsSingle

            response.SetResponseUri(builder.Uri);
              }
            }

            return response;
              }
              finally {
            appendMessageBodyStream.InternalDispose();
            appendMessageBodyStream = null;

            beginAppendAsyncResult = null;
              }
        }