I'm using the code from this link to send attachments in the email notifications of our system;
The problem is that the second attachment has encoding issue. So if i send in a text file, the text in the txt file will be all mashed up.. Like the first 23 characters are printed correctly then there is a mash of text like 'B•Ú]\ÈØ]\‹[ÝH' then it continues with the text and same thing happens after 23 characters again...
For the first attachment, I print the MIME boundary;
utl_smtp.write_data(g_mail_conn, chr(13)||chr(10)||chr(13)||chr(10)||'--' || l_boundary ||
chr(13) || chr(10));
utl_smtp.write_data( g_mail_conn, 'Content-Disposition: attachment; filename="test2.txt"' || chr(13) || chr(10));
utl_smtp.write_data( g_mail_conn, 'Content-Transfer-Encoding: base64' || chr(13) || chr(10) );
Then I run the while loop that i took from the link (copied below as well) and then after the loop, I reset the v_offset variable, then i put the same code above for the second boundary for the attachment.. Then i close the MIME boundaries at the end with
utl_smtp.write_data(g_mail_conn,chr(13) || chr(10) || '--' || l_boundary || '--' || chr(13));
Any ideas why this problem is happening?
The While loop;
<<while_loop>>
while v_offset < v_length loop
dbms_lob.read( p_blob, v_buffer_size, v_offset, v_raw );
utl_smtp.write_raw_data( c, utl_encode.base64_encode(v_raw) );
utl_smtp.write_data( c, utl_tcp.crlf );
v_offset := v_offset + v_buffer_size;
end loop while_loop;