c# auto processing email according to rules

93 Views Asked by At

I need a pattern for processing incoming emails.

My current pseudo-code is like this:

if sender is [email protected] and messageBody contains "aaa" then
   extract the content according the aaa function
   save it to database
   move the message to the archive
else if messageBody contains "bbb" then
   extract the content according to bbb function
   save it to database
   inform sender
   move the message to archive
else if messageBody NOT contains "ccc" and from "[email protected]" and then
   leave message in the inbox so the it will be manually processed
else if ...
   ...

So, I ended up with a pig function with thousands of lines.

How can I make this thing simpler?

Thanks in advance

1

There are 1 best solutions below

0
On

A very good architecture is required for solving this problem, machine learning is one of the best solution for this kind of problems. But still there are some things that you can take care of, in order to make it simpler.

  1. Rather than putting 10 ifs for 10 email-ids, create a list of unwanted users (which will go in spam)

  2. Create a list of unwanted subjects

  3. Create groups of time intervals and process emails accordingly; morning emails, noon emails, evening emails etc

  4. create has attachment check

  5. no subject check

  6. no body check

  7. friends email list

  8. same domain email-id sender check

    Thanks. :)