I have problems regarding a mail body formatting I’m sending:
Here is the KO version (no new lines):
declare
crlf VARCHAR2(2) := chr(13)||chr(10);
msg_body VARCHAR2(2000);
begin
msg_body := msg_body || ('Blablah : '|| SYSTIMESTAMP ) || crlf;
msg_body := msg_body || ('Blablah : '|| SYSTIMESTAMP ) || crlf;
EXECUTE IMMEDIATE 'ALTER SESSION SET smtp_out_server = ''127.0.0.1''';
UTL_MAIL.send(sender => 'xx@xx.com', recipients => 'yy@yy.com', subject => 'Blah', MESSAGE => msg_body);
end;
Here is the OK version (nice new lines):
declare
crlf VARCHAR2(2) := chr(13)||chr(10);
msg_body VARCHAR2(2000);
begin
msg_body := msg_body || ('Blablah : ') || crlf;
msg_body := msg_body || ('Blablah : ') || crlf;
EXECUTE IMMEDIATE 'ALTER SESSION SET smtp_out_server = ''127.0.0.1''';
UTL_MAIL.send(sender => 'xx@xx.com', recipients => 'yy@yy.com', subject => 'Blah', MESSAGE => msg_body);
end;
Best regards
The only difference between your two versions is the exclusion of SYSTIMESTAMP in the one that works.
You’re not explicitly converting your SYSTIMESTAMP to a character using
TO_CHAR(). It will be being implicitly converted according to your NLS_DATE_FORMAT instead.Convert it to a character correctly, using whatever format model you wish; for instance
ffis fractional seconds.To quote
I would recommend investigating using UTL_SMTP instead of UTL_MAIL. You don’t need to alter the session. A really simple send procedure might look like this: