コード例 #1
0
ファイル: Extensions.cs プロジェクト: wwj229/nhin-d.net35
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        /// <param name="blockSize">Avoid increasing this too much. Keep below 128K (optimal). See MSDN notes for ReadText</param>
        /// <returns></returns>
        public static string GetMessageText(this CDO.Message message, int blockSize)
        {
            ADODB._Stream stream = message.GetStream();

            int size = (int)stream.Size;

            if (size <= blockSize)
            {
                return(stream.ReadText(size));
            }

            int           countRead = 0;
            string        block     = null;
            StringBuilder builder   = new StringBuilder(size);

            while (countRead < size)
            {
                block = stream.ReadText(blockSize);
                if (string.IsNullOrEmpty(block))
                {
                    break;
                }
                builder.Append(block);
                countRead += block.Length;
            }

            return(builder.ToString());
        }