Ejemplo n.º 1
0
        /// <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());
        }
Ejemplo n.º 2
0
        public static CDO.Message LoadCDOMessageFromText(string text)
        {
            CDO.Message message = new CDO.Message();

            ADODB._Stream stream = message.GetStream();

            stream.Position = 0;
            stream.WriteText(text, StreamWriteEnum.stWriteChar);
            stream.SetEOS();
            stream.Flush();

            return(message);
        }
Ejemplo n.º 3
0
        public static void SetMessageText(this CDO.Message message, string messageText, bool save)
        {
            ADODB._Stream stream = message.GetStream();

            stream.Position = 0;
            stream.WriteText(messageText, StreamWriteEnum.stWriteChar);
            stream.SetEOS();
            stream.Flush();
            if (save)
            {
                try
                {
                    message.DataSource.Save();
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 4
0
 public static void SaveToFile(this CDO.Message message, string filePath)
 {
     ADODB._Stream stream = message.GetStream();
     stream.SaveToFile(filePath, SaveOptionsEnum.adSaveCreateOverWrite);
 }