using System;
using System.IO;
using System.Text.RegularExpressions;
namespace parse.eml
{
class Email
{
string _path,_to,_from,_subject,_urls;
public Email(string path)
{
_path = path;
string fc = new StreamReader(path).ReadToEnd();
_from = Regex.Matches(fc, "From: (.+)")[0].ToString();
_to = Regex.Matches(fc, "To: (.+)")[0].ToString();
_subject = Regex.Matches(fc, "Subject: (.+)")[0].ToString();
_urls = string.Empty;
foreach (Match m in Regex.Matches(fc,@"https?://([a-zA-Z\.]+)/"))
{
_urls += m.ToString() + ' ';
}
}
public void show()
{
Console.WriteLine(
"{0}\n\t{1}\n\t{2}\n\t{3}\n\t{4}",
_path, _to, _from, _subject, _urls);
}
}
class Program
{
static void Main(string[] args)
{
foreach (string f in Directory.GetFiles(".", "*.eml"))
{
Email e = new Email(f);
e.show();
}
}
}
}
test?