Hello,
I'm using Oracle XE 11.2 to send emails using the UTL_SMTP package, but whenever there are accents in the subject or message, it is replaced by a "?". What I have is the following:
I have a procedure that contains the parameters for sending email:
v_Mail_Conn := utl_smtp.Open_Connection(v_smtp, 25);
--autenticacao
utl_smtp.command( v_Mail_Conn, 'AUTH LOGIN');
utl_smtp.command( v_Mail_Conn, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( v_username ))) );
utl_smtp.command( v_Mail_Conn, utl_raw.cast_to_varchar2( utl_encode.base64_encode( utl_raw.cast_to_raw( v_pwd ))) );
--Conexao
utl_smtp.Helo(v_Mail_Conn, v_smtp);
utl_smtp.Mail(v_Mail_Conn, v_from);
utl_smtp.Rcpt(v_Mail_Conn, v_to);
--MENSAGEM SEM ANEXO TEXTO PLANO
/*utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_from || crlf ||
'Subject: '|| v_assunto || crlf ||
'To: ' || v_to || crlf ||
crlf || v_message || ''
);*/
--MENSAGEM SEM ANEXO HTML
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_from || crlf ||
'Subject: '|| v_assunto || crlf ||
'To: ' || v_to || crlf ||
'MIME-Version: 1.0'|| crlf || -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| crlf ||
' boundary="-----SECBOUND"'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/html; charset="UTF-8"'|| crlf ||
'Content-Transfer-Encoding: 8bit'|| crlf ||
crlf ||
v_message ||
crlf);
From my research, I noticed that the problem may be in this part:
utl_smtp.Data(v_Mail_Conn,
'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
'From: ' || v_from || crlf ||
'Subject: '|| v_assunto || crlf ||
'To: ' || v_to || crlf ||
'MIME-Version: 1.0'|| crlf || -- Use MIME mail standard
'Content-Type: multipart/mixed;'|| crlf ||
' boundary="-----SECBOUND"'|| crlf ||
crlf ||
'-------SECBOUND'|| crlf ||
'Content-Type: text/html; charset="UTF-8"'|| crlf ||
'Content-Transfer-Encoding: 8bit'|| crlf ||
crlf ||
v_message ||
crlf);
I'm setting 8bit and UTF-8, but even changing the charset it still sends the "?" as a message.
I searched for UTL_ENCODE.QUOTED_PRINTABLE_ENCODE
and set content-transfer-encoding to be quoted-printable, but I still continue with the error.
These are the NLS language parameters:
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS .
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_CHARACTERSET AL32UTF8
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_DUAL_CURRENCY $
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE