0

send an email automatically when a date is reached

Good morning,

 

I would like to be able to run a script that automatically sends an email on a date to a contact and my email as a copy.

I have already written the script (which works) but in a formula field of the "CLIENT" table.

 

let daterv := 'RV ENTRETIEN';

let daterappel := rappel;

let currentdate := today();

 

if currentdate = daterappel then

let recipient1 := 'E-mail';

let recipient2 := "xxx@yyy.net";

 

sendEmail({

from: "xxx@yyy.net",

to: 'E-mail',

cc: "xxx@yyy.net",

subject: "Ceci est un email de rappel " + " " + year('RV ENTRETIEN') + " " + NOM + " " + PRENOM + " " + VILLE,

text: " ",

html: "Bonjour ceci est un rappel pour vous signaler que l'entretien est prévu dans 15 jours, " +

"le " + 'RV ENTRETIEN' + "<p><b>Afin d'éviter un déplacement inutile,<font color=red>veuillez confirmer votre présence le jour de l'entretien en répondant à ce mail POUR ACCORD, merci</font></b></p>"

})

end

 

When I manually execute this script, the email is sent to both addresses.

The date condition is respected, so if I try to send the email on another date, it doesn't work.

 

But how can I automate this script so that it checks every day which customers to send the email to? ....and send the email.

 

The table is CLIENT

 

If you would like further information, do not hesitate.

 

Thank you for your answers

 

O Vrancken

3 replies

null
    • Mel_Charles
    • 5 mths ago
    • Reported - view

    Have you tried calling it from the global scripts.?

    so when you log on it fires any/all emails off

    • info.10
    • 5 mths ago
    • Reported - view

    Hi,

     

    I've put this code in "Trigger after open"

    let test := (select CLIENT where rappel = today()).NOM;
    let c := (select CLIENT where rappel = today());
    for i in select CLIENT where rappel = today() do
        let recipient1 := (select CLIENT).'E-mail';
        let recipient2 := "info@company.com";
        let rvent := (select CLIENT).'RV ENTRETIEN';
        let anneervent := (select CLIENT).'ANNEE ENTRETIEN';
        sendEmail({
            from: "info@company.com",
            to: recipient1,
            cc: recipient2,
            subject: "Ceci est un email de rappel d'entretien d'alarme" + " " +
            (select CLIENT).'ANNEE ENTRETIEN' +
            " " +
            (select CLIENT).NOM +
            " " +
            (select CLIENT).PRENOM +
            " " +
            (select CLIENT).VILLE,
            text: " ",
            html: "Bonjour ceci est un rappel pour vous signaler que l'entretien de votre système d'alarme est prévue dans 15 jours, " +
            "le " +
            rvent +
            "<p><b>Afin d'éviter un déplacement inutile,<font color=red>veuillez confirmer votre présence le jour de l'entretien en répondant à ce mail POUR ACCORD, merci</font></b></p>"
        })
    end
    

    mails are sent, but all records in CLIENT table are sent in unique mail.

    what I would like is for each record found (today) to receive an email and not all records
    I think it can be done with the for loop but I can't format this loop to do it

    Can you help me on this?

    THANKS

    • Mel_Charles
    • 4 mths ago
    • Reported - view

    as you seem okay with scripting

    Here is an extract of one of mine that loops through 150 emails at a time

    (i have 150 to control the batches going out)

    using myVar variable

    You should be able to strip out the bits you need

    let a := (select Contacts where GDPR_Status = 1 and EmailSend);
    for myVar in slice(a, 0, 150) do
        let xEmail := myVar.Email;
        let myEmail := userEmail();
           sendEmail({
            from: myEmail,
            to: myVar.Email,
            subject: "Your goods have been dispatched",
            text: " ",

    html: " ect etc etc"

        });
     end

Content aside

  • 4 mths agoLast active
  • 3Replies
  • 88Views
  • 2 Following