BOnjour a tous

J'essaie de tester la procedure html_email trouvé ici et ailleurs

mais je n'arrive pas a affichier le contenu d'une table en corps du message.

NB je ne veux pas envoyer par fichier joint , pour l'instant.

voici le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
CREATE OR REPLACE procedure OWNER_HISTO.html_email(
p_to in varchar2,
p_from in varchar2,
p_subject in varchar2,
p_text in varchar2 default null,
p_html in varchar2 default null,
p_smtp_hostname in varchar2,
p_smtp_portnum in varchar2)
is
l_boundary varchar2(255) default 'a1b2c3d4e3f2g1';
l_connection utl_smtp.connection;
l_body_html clob := empty_clob; --This LOB will be the email message
l_offset number;
l_ammount number;
l_temp varchar2(32767) default null;
ligne varchar2(2000);
begin
l_connection := utl_smtp.open_connection( p_smtp_hostname, p_smtp_portnum );
utl_smtp.helo( l_connection, p_smtp_hostname );
utl_smtp.mail( l_connection, p_from );
utl_smtp.rcpt( l_connection, p_to );
l_temp := l_temp || 'MIME-Version: 1.0' || chr(13) || chr(10);
l_temp := l_temp || 'To: ' || p_to || chr(13) || chr(10);
l_temp := l_temp || 'From: ' || p_from || chr(13) || chr(10);
l_temp := l_temp || 'Subject: ' || p_subject || chr(13) || chr(10);
l_temp := l_temp || 'Reply-To: ' || p_from || chr(13) || chr(10);
l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' ||
chr(34) || l_boundary || chr(34) || chr(13) ||
chr(10);
----------------------------------------------------
-- Write the headers
dbms_lob.createtemporary( l_body_html, false, 10 );
dbms_lob.write(l_body_html,length(l_temp),1,l_temp);
----------------------------------------------------
-- Write the text boundary
l_offset := dbms_lob.getlength(l_body_html) + 1;
l_temp := '--' || l_boundary || chr(13)||chr(10);
l_temp := l_temp || 'content-type: text/plain; charset=us-ascii' ||
chr(13) || chr(10) || chr(13) || chr(10);
dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
----------------------------------------------------
-- Write the plain text portion of the email
l_offset := dbms_lob.getlength(l_body_html) + 1;
dbms_lob.write(l_body_html,length(p_text),l_offset,p_text);
----------------------------------------------------
-- Write the HTML boundary
l_temp := chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
chr(13) || chr(10);
l_temp := l_temp || 'content-type: text/html;' ||
chr(13) || chr(10) || chr(13) || chr(10);
l_offset := dbms_lob.getlength(l_body_html) + 1;
dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
----------------------------------------------------
-- Write the HTML portion of the message
          ligne := ' NEXT DIVIDENDS :'
             ||  UTL_TCP.crlf ||  UTL_TCP.crlf;
   --          || RPAD ('TICKER',30,' ')
   --          || RPAD ('ANNOUNCEMENT_DATE',30,' ')
   --          || RPAD ('EX_DATE',20,' ')
   --          || RPAD ('PAY_DATE',10,' ');
                 l_boundary := ligne || UTL_TCP.crlf;
-- SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO l_boundary FROM dual;
  for j in (select ticker,
       (decode (announcement_date,to_date(sysdate,'DD/MM/YYYY'), '*'|| announcement_date,to_char (announcement_date,'DD/MM/YYYY')) ) announcement_date ,
       ( decode ( ex_date,to_date(sysdate,'DD/MM/YYYY') ,'*'|| ex_date , to_char (ex_date,'DD/MM/YYYY') )) ex_date ,
       ( decode  (pay_date ,to_date(sysdate,'DD/MM/YYYY') ,'*'|| pay_date , to_char (pay_date,'DD/MM/YYYY') )) pay_date
       from
              corp_act_div_temp
              where past_futur='FUTURE'
              and ex_date = to_date(sysdate,'DD/MM/YYYY')
              or pay_date = to_date(sysdate,'DD/MM/YYYY')
              or announcement_date= to_date(sysdate,'DD/MM/YYYY')
              order by ticker)
   loop
      dbms_output.put_line(j.ticker ||', '||j.announcement_date||', '||j.ex_date||', '||j.pay_date);
              ligne :=
                        RPAD(j.ticker,20)
                          ||j.announcement_date
                          ||j.ex_date
                         ||j.pay_date ;
              l_boundary := l_boundary || ligne || UTL_TCP.crlf;
l_offset := dbms_lob.getlength(l_body_html) + 1;
dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
dbms_lob.write(l_body_html,length(l_boundary),l_offset, l_boundary);
end loop;
----------------------------------------------------
-- Write the final html boundary
l_temp := chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13);
l_offset := dbms_lob.getlength(l_body_html) + 1;
dbms_lob.write(l_body_html,length(l_temp),l_offset,l_temp);
----------------------------------------------------
-- Send the email in 1900 byte chunks to UTL_SMTP
l_offset := 1;
l_ammount := 1900;
utl_smtp.open_data(l_connection);
while l_offset < dbms_lob.getlength(l_body_html) loop
utl_smtp.write_data(l_connection,
dbms_lob.substr(l_body_html,l_ammount,l_offset));
l_offset := l_offset + l_ammount ;
l_ammount := least(1900,dbms_lob.getlength(l_body_html) - l_ammount);
end loop;
utl_smtp.close_data(l_connection);
utl_smtp.quit( l_connection );
dbms_lob.freetemporary(l_body_html);
end;
/
j'ai change la section

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- Write the HTML portion of the message
          ligne := ' NEXT DIVIDENDS :'
             ||  UTL_TCP.crlf ||  UTL_TCP.crlf;
   --          || RPAD ('TICKER',30,' ')
   --          || RPAD ('ANNOUNCEMENT_DATE',30,' ')
   --          || RPAD ('EX_DATE',20,' ')
   --          || RPAD ('PAY_DATE',10,' ');
                 l_boundary := ligne || UTL_TCP.crlf;
-- SELECT TO_CHAR(SYSDATE,'MM/DD/YYYY HH24:MI:SS') INTO l_boundary FROM dual;
  for j in (select ticker,
       (decode (announcement_date,to_date(sysdate,'DD/MM/YYYY'), '*'|| announcement_date,to_char (announcement_date,'DD/MM/YYYY')) ) announcement_date ,
       ( decode ( ex_date,to_date(sysdate,'DD/MM/YYYY') ,'*'|| ex_date , to_char (ex_date,'DD/MM/YYYY') )) ex_date ,
       ( decode  (pay_date ,to_date(sysdate,'DD/MM/YYYY') ,'*'|| pay_date , to_char (pay_date,'DD/MM/YYYY') )) pay_date
       from
              corp_act_div_temp
              where past_futur='FUTURE'
              and ex_date = to_date(sysdate,'DD/MM/YYYY')
              or pay_date = to_date(sysdate,'DD/MM/YYYY')
              or announcement_date= to_date(sysdate,'DD/MM/YYYY')
              order by ticker)
   loop
      dbms_output.put_line(j.ticker ||', '||j.announcement_date||', '||j.ex_date||', '||j.pay_date);
              ligne :=
                        RPAD(j.ticker,20)
                          ||j.announcement_date
                          ||j.ex_date
                         ||j.pay_date ;
              l_boundary := l_boundary || ligne || UTL_TCP.crlf;
l_offset := dbms_lob.getlength(l_body_html) + 1;
dbms_lob.write(l_body_html,length(p_html),l_offset,p_html);
dbms_lob.write(l_body_html,length(l_boundary),l_offset, l_boundary);
end loop;

donc comment faire pour afficher le contenu de ma table ?