FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Send Unicode email with Oracle

 


shamil
I know this is not right place for discussing Oracle related issues. But http://www.frihost.com/forums/vt-59029.html

Solved. Below code is oracle procedure which sends unicode characters contained mail. I use it to send mail to Outlook. Hope this will be usefull to who needs it. Here is the code:
Code:
create or replace procedure sendMail(
   p_recipient_email varchar2,
   p_recipient_alias varchar2,
   p_subj varchar2,
   p_body varchar2,
   p_mailserv varchar2   
  ) is
    subj raw(2000) := utl_raw.cast_to_raw('Subject: '||p_subj|| UTL_TCP.CRLF);
    bod raw(32000) := utl_raw.cast_to_raw(p_body);
    c UTL_SMTP.CONNECTION;
    PROCEDURE send_header(name IN VARCHAR2, header IN VARCHAR2) AS
    BEGIN
      UTL_SMTP.WRITE_DATA(c, name || ': ' || header || UTL_TCP.CRLF);
    END;
  BEGIN
    c := UTL_SMTP.OPEN_CONNECTION(p_mailserv);
    UTL_SMTP.HELO(c, 'mail.mydomain.com');
    UTL_SMTP.MAIL(c, 'supervisor@box.az');
    UTL_SMTP.RCPT(c, p_recipient_email);
    UTL_SMTP.OPEN_DATA(c);
    send_header('From','"Shamil" <supervisor@box.az>');
    send_header('To',p_recipient_alias||' '||p_recipient_email);
    UTL_SMTP.write_raw_data(c,subj);
    send_header('Content-Type', 'text/html;charset=utf-8');
    UTL_SMTP.write_raw_data(c, bod);
    UTL_SMTP.CLOSE_DATA(c);
    UTL_SMTP.QUIT(c);
  EXCEPTION
    WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
      BEGIN
        UTL_SMTP.QUIT(c);
      EXCEPTION
        WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
          NULL;
      END;
      raise_application_error(-20000,
        'Failed to send mail due to the following error: ' || sqlerrm);
end sendMail;
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.