0

I have a mysql table with 3 columns:

  • email_address
  • email_message
  • message_status

I need to create an application that keeps track of this table and whenever a message is inserted into the table with a message status of 0, the application should send the email message and update the message status to 1.

Philipp Reichart
  • 20,771
  • 6
  • 58
  • 65
  • People appreciate it if you give more information, especially what you have already tried. And welcome, by the way! – Mattsjo Aug 15 '13 at 10:12
  • Please be more specific with your question. What is the element you're struggling with? Polling the table? Sending the e-mail? Updating the table? – Andy_D Aug 15 '13 at 10:17
  • Help with what? What is your question? StackOverflow is a site for questions and answers. You need to ask a question - what you have given us is a project, not a question. We will not do projects for you. – J... Aug 15 '13 at 10:30
  • Btw, you need to say what is going to be inserting the email in the table, your app or another one. If the latter, you may need to read up on triggers in MySql. – MartynA Aug 15 '13 at 10:38
  • It would be very helpful to know what database you are using. Using triggers you could probably have the database do this by itself without needing a delphi application at all. See : http://stackoverflow.com/a/10755518/327083 – J... Aug 15 '13 at 10:46
  • possible duplicate of [How to send email from MySQL 5.1](http://stackoverflow.com/questions/387483/how-to-send-email-from-mysql-5-1) – mjn Aug 16 '13 at 06:16

2 Answers2

2

Don't poll the DB for changes!

You will need a TRIGGER ON INSERT and probably some kind of UDF function.

If you don't want to write your own UDF, try to look at http://www.mysqludf.org/ in the "sys" repository. You will be able to "invoke shell commands" from MySQL. Please think of the security implication if you do that!

Sylvain Leroux
  • 50,096
  • 7
  • 103
  • 125
1

With your query (Tquery,myquery, uniquery.. which you use) you can set a action using fields editor, Choose the field and set its onchange property to your mail function.In your function check the status of the message that you insert.If bool is true send the message and update status.

If you have much more data you can append the message info in clientdata or memdata and end of query you can send them.

Murat
  • 11
  • 2