我知道你說沒有外部庫,但我有一個圖書館張貼在CodePlex上:
https://bitbucket.org/otac0n/mailutilities
MimeMessage msg = new MimeMessage(/* string, stream, or Byte[] */);
它已與超過40,000現實世界的郵件進行測試。
我不是太高興我的名字空間的選擇,但是......我懶得去改變它。
PS:
在內部,我的圖書館使用這些正則表達式的語法分析器:
internal static string FullMessageMatch =
@"\A(?<header>(?:[^\r\n]+\r\n)*)(?<header_term>\r\n)(?<body>.*)\z";
internal static string HeadersMatch =
@"^(?<header_key>[-A-Za-z0-9]+)(?<seperator>:[ \t]*)(?<header_value>([^\r\n]|\r\n[ \t]+)*)(?<terminator>\r\n)";
internal static string HeaderSeperator =
"\r\n";
internal static string KeyValueSeparator =
@"\A:[ \t]*\z";
微軟CDO,這裏解釋:http://stackoverflow.com/questions/936422/recommendations-on-parsing-e ml-files-in-c-sharp(我知道這很舊,只是將它發佈給那些後來像我這樣發現的人) – eselk 2013-03-23 03:48:51