1
Hello,
I am using Oracle XE 11.2 to send emails using the UTL_SMTP package, but whenever there are accents to the subject or message, it is replaced by a "?". Here’s what I got:
I have a protocol 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’ve 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);
Because I am defining 8bit and UTF-8, but even changing the charset it still keeps sending the "?" as message.
I researched about the UTL_ENCODE.QUOTED_PRINTABLE_ENCODE
and set content-transfer-encoding as quoted-printable, but still continue with the error.
These are the language parameters of NLS:
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
How are the "Parameters" of language and territory ? https://docs.oracle.com/cd/E18283_01/appdev.112/e10766/tdddg_globalization.htm#CACIIJGI
– Motta
The parameters are in the question. As an interim solution I encoded all accents in html, it seems to work but is not the best thing
– KhaosDoctor
I don’t think it’s a bad solution, because the email looks better , what we use in the company where I work is just text I started doing in html. Tried to switch the Session language to Portuguese or CHARACTERSET ?
– Motta
So, the big problem is that we also had accent errors in the application that were fixed, I don’t know if changing the language can result in the return of problems, I think I’ll leave with the html Markup.
– KhaosDoctor