views:

45

answers:

3

Hey guys here's a good question..

I wanted to write a program that can receives an email, interprets what the message is, then performs a calculation, then responds based on the email received.

For example... The mail server receives an email that has "option 1" in the body...then somehow the mail server asks the program what it should do in the event of option 1. The program performs some calculations, then asks a SQL server to relay some data related to option 1 . The mail server then returns a dynamically created message "option 1 means xxx".

I really have no idea where to start on this one. A friend recommended PostFix but I'm not exactly sure where any program logic can be performed. Any ideas or suggestions are welcome.

A: 

You can do this using a regular POP3/IMAP and SMTP setup.

  1. Monitor the Mailbox for incoming messages
  2. Download the message and parse the contents
  3. Process your events as needed
  4. Generate a SMTP response to the sender and respond.

Some helpful links:

  1. System.Net.Mail
  2. Processing POP3 messages in C#

P.S. We have done this at several jobs I have worked at, its actually very straight forward.

GrayWizardx
A: 

The procmail mail processor is very good at this. Examples should be in the documentation. It essentially allows you strip mail bodies from headers given conditions (e.g. 'security' tokens, 'passwords', 'addresses', ...) and to then pipe the mail body through other arbitrary programs.

Dirk Eddelbuettel
A: 

Chris, I started here: codeproject - NetPopMimeClient. Using this I wrote a program to check for a new inventory email based on subject text (inventory attached.) When I found a new one I would save the attachment and then upload it to my sql server and kick off a stored proc to process it. Then saved the email DateTime stamp for the next run and to display to the user on the front-end.

I created a Console Application that is scheduled in SQL Server Agent. I did this so I can have a log of activity, it is close to the database, it is easy to kick off manually, and it emails out when there is a problem.

Jim

JBrooks