parsing eml files with c#
2009-05-22 15:21
357 查看
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?
[/code]
相关文章推荐
- Parsing XML Files with PowerShell
- Parsing XML Files with PowerShell
- Decompiling CHM (help) files with C#
- [转]Parsing Text and Binary Files With Erlang
- Working with Files in C#
- Parsing XML Files with SAX
- Reading-Writing PGM(Portable Graphics Media) Image Files With C#(C Sharp)
- Working with PDF files in C# using PdfBox and IKVM
- Upload files in ASP.NET MVC with JavaScript and C#
- Tutorial: Loading and parsing external XML and JSON files with Unity
- Creating Custom UITableViewCells with NIB files
- Exception handling with custom error pages in ASP.NET using C#.
- Developing ASP.NET Custom Control With C# Builder
- c# instantly kill thread with TerminateThread (danger)
- Introduction to DataSets and working with XML files
- Configure Midnight Commander to open files with custom application
- Calling Win32 DLLs in C# with P/Invoke(节录)
- Create XML Files Out Of SQL Server With SSIS And FOR XML Syntax
- Reading/Writing files with MSSQL's OPENROWSET
- 【C#】45. Task ContinueWith 后续操作