DECLARE
TESTEMAIL VARCHAR2(100);
TESTNAME VARCHAR2(100);
EMAIL_LIST VARCHAR2(100);
EMAIL_NAME VARCHAR2(100);
EMAIL_COUNT NUMBER;
BEGIN
SELECT COUNT(*) INTO EMAIL_COUNT FROM TEST_EMAIL;
FOR i IN 1..EMAIL_COUNT
LOOP
SELECT TESTEMAIL INTO EMAIL_LIST FROM TEST_EMAIL WHERE ID = i;
SELECT TESTNAME INTO EMAIL_NAME FROM TEST_EMAIL WHERE ID = i;
APEX_MAIL.SEND(
p_to => EMAIL_LIST ,
p_from => 'admin@solatoz.com',
p_subj => :P5_SUBJECT,
p_body => 'Please Check email.',
p_body_html => 'Dear' || ' '|| EMAIL_NAME || ',' || :P5_BODY
);
END LOOP;
END;