ETL to administrate new users and send them an E-mail

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • ETL to administrate new users and send them an E-mail

      Hello,

      I wanted to ask, whether somebody has tried to create an E-mail (with groovy) and send it to specified users out of an ETL-Job?

      Context:
      I created an ETL project that creates new users with the respective properties and groups.
      See image:
      2019-09-20 12_03_50-jedox_user_administration.png

      I would like also to automate the Mail to those new users with a short description how to access Jedox and change the initial Password. Since the information is already in the source file and respective field transform, I was wandering whether it is possible for a groovy Job to send a mail. Or is it only possible to set up notification mails for the result of an executed job?

      Many thanks in advance for any ideas.

      BR
      Bjoern
    • This is how we did it:
      knowledgebase.jedox.com/knowledgebase/scripting-api/

      Source Code

      1. mailer = API.getMailer();
      2. mailer.setServer();
      3. /* for 2 recipients */
      4. mailer.addRecipient("changeme@gmail.com");
      5. mailer.addRecipient("changeme2@gmail.com");
      6. mailer.setSubject("ETL Test Mail");
      7. mailer.setMessage("Hello! here are the files.");
      8. /* with 2 attachements */
      9. mailer.addAttachment("FileToOlap.csv");
      10. mailer.addAttachment("BikerOrderlines.csv");
      11. mailer.send();
      Display All
    • After some further research and a lot of trial and error, I've finally found a solution.
      If anybody has a similar need, it might come in handy.

      Source Code

      1. def maillist = API.initSource("t_ft_NewUser_MailList");
      2. while (row = maillist.nextRow()) {
      3. rowUser = maillist.getColumnValue("user");
      4. rowemail = maillist.getColumnValue("email");
      5. rowname = maillist.getColumnValue("FirstName");
      6. rowpassword = maillist.getColumnValue("password");
      7. rowMailbody = maillist.getColumnValue("Mailbody");
      8. rowfullName = maillist.getColumnValue("fullName");
      9. mailer = API.getMailer();
      10. mailer.setServer();
      11. mailer.addRecipient(rowemail);
      12. mailer.addRecipient ("functionmailbox@company.com")
      13. mailer.setSubject("Acccount Data Jedox");
      14. mailer.setMessage(rowMailbody);
      15. try {
      16. mailer.send();
      17. LOG.info("User: "+rowUser+" | E-Mail: "+rowemail+" | Name: "+rowfullName);
      18. mailer.reset();
      19. }
      20. catch(all){
      21. LOG.warn("Email delivery FAILED");
      22. }
      23. int seconds = 1; //wait for mailer to clean up data
      24. LOG.info("Waiting for" +seconds+" seconds to clean up data");
      25. Thread.sleep(seconds*500);
      26. }
      Display All
      In the FieldTransform ("t_ft_NewUser_MailList") is already everything set up that is needed for the mail being send with the groovy job, including the MailBody (via Groovy Function with multiline strings), since I didn't know whether this function would work with HTML formatting.