I have a table with a list of several different emails and Items. I'm trying to send out an email (whenever a button is pressed) to all of those emails with their Items, e.g.:
An email like this should be send when the button is pressed:
"Dear [email protected], your cart is ready with item 1 and item 2."
I know how to send emails using Apex Items but I'm lost on how to do it with information inside a table. Does anyone know how to do that?
Thanks!
CodePudding user response:
This might be one option: create a procedure which runs when button is pressed; it reads table contents and "aggregates" list of items into message text.
As you already know how to send mail, I hope this is enough for you to make it work.
SQL> with test (user_email, item) as
2 -- sample data
3 (select '[email protected]', 'item 1' from dual union all
4 select '[email protected]', 'item 2' from dual union all
5 --
6 select '[email protected]', 'item 1' from dual union all
7 select '[email protected]', 'item 2' from dual union all
8 select '[email protected]', 'item 3' from dual
9 )
10 -- code you might be interested in
11 select user_email,
12 'Dear ' || user_email ||', your cart is ready with ' ||
13 listagg(item, ', ') within group (order by item) as message_text
14 from test
15 group by user_email
16 /
USER_EMAIL MESSAGE_TEXT
------------ ----------------------------------------------------------------------
123@mail.com Dear 123@mail.com, your cart is ready with item 1, item 2, item 3
abc@mail.com Dear abc@mail.com, your cart is ready with item 1, item 2
SQL>