build a system or mail server to parse the email format to extract the text in C#
Is 开发者_运维知识库it possible to build a system or mail server/service to receive and parse it to extract the text in C#?
Does anyone do it before?
Best Regards,
In our company, we have a windows service that does this:
- connect to an email account;
- download the messages to a database;
- looks the messages for a specific string, indicating an IP address;
- save to another table to be processed later.
If I correctly understood your question, you could do the same thing.
Are you asking if it is possible to write a mail-server in C#?
Of course it is. I didn't see any MailServer objects that'll handle this for you, however you could just as easily read the RFCs involved (http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol) and write it using the TCPClient classes.
I've used the Mime4Net library for the parsing very effectively. Email is not a format you want to hand code parsing for. The standard is HUGE and rather complicated.
It might be better to ignore dedicated parser/lexer to do this as the standards for email vary wildly depending on the email transporter, or you can simply ignore the email headers...the only snag is if the email is composed of MIME data...use this Mime4Net to handle this for you or browse around in the open source directory of C# to find the right solution for you.
Hope this helps, Best regards, Tom.
精彩评论