सबसे पहले, यह एक मुश्किल काम है।
आपको अलग-अलग ई-मेल क्लाइंट से विशिष्ट प्रतिक्रियाएं एकत्र करनी चाहिए और उन्हें पार्स करने के लिए सही नियमित भाव (या जो भी) तैयार करना चाहिए। मैंने आउटलुक, थंडरबर्ड, जीमेल, ऐप्पल मेल और mail.ru से प्रतिक्रियाएं एकत्र की हैं।
मैं निम्नलिखित तरीके से प्रतिक्रिया को पार्स करने के लिए नियमित अभिव्यक्ति का उपयोग कर रहा हूं: यदि अभिव्यक्ति का मिलान नहीं हुआ, तो मैं अगले एक का उपयोग करने का प्रयास करता हूं।
new Regex("From:\\s*" + Regex.Escape(_mail), RegexOptions.IgnoreCase)
new Regex("<" + Regex.Escape(_mail) + ">", RegexOptions.IgnoreCase)
new Regex(Regex.Escape(_mail) + "\\s+wrote:", RegexOptions.IgnoreCase)
new Regex("\\n.*On.*(\\r\\n)?wrote:\\r\\n", RegexOptions.IgnoreCase | RegexOptions.Multiline)
new Regex("-+original\\s+message-+\\s*$", RegexOptions.IgnoreCase)
new Regex("from:\\s*$", RegexOptions.IgnoreCase)
अंत में उद्धरण हटाने के लिए:
new Regex("^>.*$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
यहाँ परीक्षण प्रतिक्रियाओं का मेरा छोटा सा संग्रह है ( --- द्वारा विभाजित नमूने ):
From: test@test.com [mailto:test@test.com]
Sent: Tuesday, January 13, 2009 1:27 PM
----
2008/12/26 <test@test.com>
> text
----
test@test.com wrote:
> text
----
test@test.com wrote: text
text
----
2009/1/13 <test@test.com>
> text
----
test@test.com wrote: text
text
----
2009/1/13 <test@test.com>
> text
> text
----
2009/1/13 <test@test.com>
> text
> text
----
test@test.com wrote:
> text
> text
<response here>
----
--- On Fri, 23/1/09, test@test.com <test@test.com> wrote:
> text
> text
सादर, ओलेग यारोशेविक