Exemple #1
0
        public ToxyEmail Parse()
        {
            if (!File.Exists(Context.Path))
                throw new FileNotFoundException("File " + Context.Path + " is not found");

            ToxyEmail email = new ToxyEmail();
            using (FileStream stream = File.OpenRead(Context.Path))
            {
                EMLReader reader = new EMLReader(stream);
                email.From = new List<string>(reader.From.Split(';'));
                email.To = new List<string>(reader.To.Split(';'));
                email.Cc = new List<string>(reader.CC.Split(';'));
                email.Body = reader.Body;
                email.HtmlBody = reader.HTMLBody;
                email.Subject = reader.Subject;
                email.ArrivalTime = reader.X_OriginalArrivalTime;
            }

            return email;
        }
Exemple #2
0
        public override string Parse()
        {
            if (!File.Exists(Context.Path))
                throw new FileNotFoundException("File " + Context.Path + " is not found");

            StringBuilder sb = new StringBuilder();
            using (FileStream stream = File.OpenRead(Context.Path))
            {
                EMLReader reader = new EMLReader(stream);
                if (!string.IsNullOrEmpty(reader.From))
                    sb.AppendFormat("[From] {0}{1}",reader.From, Environment.NewLine);
                if (!string.IsNullOrEmpty(reader.To))
                    sb.AppendFormat("[To] {0}{1}", reader.To, Environment.NewLine);
                if (!string.IsNullOrEmpty(reader.CC))
                    sb.AppendFormat("[CC] {0}{1}", reader.CC, Environment.NewLine);
                if (!string.IsNullOrEmpty(reader.Subject))
                    sb.AppendFormat("[Subject] {0}{1}", reader.Subject, Environment.NewLine);

                sb.AppendLine();
                sb.AppendLine(reader.Body);
                //sb.AppendLine(reader.HTMLBody);
            }
            return sb.ToString();
        }