Hello,
I write a package to attach CLOBs to mails as an attachment. While generating the attachment works (they are shown as attachments in my mailprogramm) the content is not complete.
The attachments are CLOBs (XML files) and I tried to use UTL_ENCODE.BASE64 to keep non-ASCII characters unchanged.
The encoding is done as in this example
DECLARE
v_data VARCHAR2(20) := 'Short text';
v_data2 VARCHAR2(50);
BEGIN
v_data2 := utl_encode.text_encode(
v_data
,'WE8ISO8859P15'
,UTL_ENCODE.BASE64
);
dbms_output.put_line('v_data2 '||v_data2);
v_data := utl_encode.text_decode(
v_data2
,'WE8ISO8859P15'
,UTL_ENCODE.BASE64
);
dbms_output.put_line('v_data '||v_data);
END;
/
I try to write the encoded data with
utl_smtp.write_data(v_conn,v_data2);
but then not the complete information is written.
Here is part of the raw mail as it gets sent
Content-Type: multipart/mixed; boundary="SLD.e3831dfcf821d45d9bf900b4745fe"
Mailtext outside attachments
--SLD.e3831dfcf821d45d9bf900b4745fe
Content-Type: text/plain; charset = "iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Mailtext outside attachments
--SLD.e3831dfcf821d45d9bf900b4745fe
Content-Type: application/octet-stream; name="text.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="text.txt"
b2YgYXQgbGVh
c3QgMTAwIG9yIG1vcmUgc29tZSBub25zZW5zZSBvciBlbHNlIG5vdyBpbSB0aGVy
ZQ==
--SLD.e3831dfcf821d45d9bf900b4745fe
Content-Type: application/octet-stream; name="text2.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="text2.txt"
--SLD.e3831dfcf821d45d9bf900b4745fe--
The second attachment (text2.txt) should contain the text generated in my example
U2hvcnQgdGV4dA==
The text of the first file is
This is a longer text with some Umlaute ÄÖÜßäöü of at least 100 or more some nonsense or else now im there
and is translated to these two strings
"VGhpcyBpcyBhIGxvbmdlciB0ZXh0IHdpdGggc29tZSBVbWxhdXRlIMTW3N/k9vwg
b2YgYXQgbGVh"
"c3QgMTAwIG9yIG1vcmUgc29tZSBub25zZW5zZSBvciBlbHNlIG5vdyBpbSB0aGVy
ZQ=="
but as you can see in the mail they are only partly written.
Any idea why? Or what is the best way to convert a CLOB to base64 in the correct chunk size?
Regards
Marcus