Frage

I have a daily process which sends me(actually the entire group) an email with two attachments zipped into one. I download the zip file, unzip it and forward one of the files out of the two to another group. The file which I forward after unzipping has a constant name pattern(for instance, it will always begin with ABC_Daily_*). I have to do this daily.

I want this to be automated. I am thinking of a windows service which will do the following:

  1. Poll the mail server(keep looking for a mail with a particular subjectline and sender)
  2. When the required mail comes to inbox, it will read the mail and download the zip file to a shared location.
  3. unzip the zip.
  4. As soon as the files get unzipped, the required file will be watched by a file watcher process and forwarded as an attachment to the required group.

Points 3-4 will be easy for me as I have done some work on it earlier. But I do not know how to know when a mail comes to a group's inbox. I do not know how to read the mail automatically and perform the actions mentioned.

Could you please guide through my problem? Any other ideas for implementing apart from the one I have mentioned are most welcome.

War es hilfreich?

Lösung

I implemented a similar system a few years ago. What I did was implement a windows service which polled an exchange mailbox every X seconds and processed the emails in batches. One tip - depending on how frequent you need to poll you might find a console app driven by a scheduled task is more efficient (and less work).

For the actual mailbox interaction I used a couple of 3rd party libraries for processing and parsing the mail, pretty straightforward.

The difficulty with a system like this is making sure that emails are processed only once and dealing with problematic emails accordingly without blocking the service. For me it was as simple as moving the emails around into specific folders i.e. Processing or Deadletter.

I also had my service setup to email me reports on things like queue size, deadletter emails and any other general errors.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top