Topic: Reminder

Hi All,
please have a look at the following script, after the email is sent, I want that reminder to be deleted from the database. I just don't know how to type the script for that,

procedure OnTimer;
var sMessage: string;
begin
     sMessage := SQLExecute('SELECT message FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) <= strftime(''%d.%m.%Y %H:%M'', ''now'', ''localtime'') ');
     if SendMail('smtp.mail.xxxx.your-server.de', 'notification@qualitymanagementsystems.eu', 'xxxxxxxx', 465, 'notification@qualitymanagementsystems.eu', 'wayne.hollowayr@gmail.com' , 'Subject', 'Message') then
            //else if  SQLExecute('SELECT message FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) < strftime(''%d.%m.%Y %H:%M'', ''now'', ''localtime'') ') then HERE SOME TYPE OF SCRIPT TO DELETE THE REMINDER IN THE DATABASE

          Begin
         // Form1.Button3.click;
          end;
end;

2 (edited by ehwagner 2021-03-20 23:40:43)

Re: Reminder

Try this: (Not tested for syntax)

procedure OnTimer;
var sMessage,sId: string;
begin
     sId := SQLExecute('SELECT id FROM reminder WHERE strftime(''%d.%m.%Y %H:%M'', datetime) <= strftime(''%d.%m.%Y %H:%M'', ''now'',''localtime'') ');
    If sId <> '' then
      Begin
         sMessage := SQLExecute('SELECT message FROM reminder WHERE id = ' +sId);
         if SendMail('smtp.mail.xxxx.your-server.de', 'notification@qualitymanagementsystems.eu', 'xxxxxxxx', 465, 
           'notification@qualitymanagementsystems.eu', 'wayne.hollowayr@gmail.com' , 'Subject', 'Message') then
            SqlExecute('Delete From reminder where id = '+ sId);  // Here is your delete record statement
      End;

      // I commented the following. Not legitimate.
          //Begin
         // Form1.Button3.click;
         // end;
end;

Re: Reminder

Hi,

Thank you very much ill give it a try.

Regards

Wayne