• <tfoot id='vAmu0'></tfoot>
    <i id='vAmu0'><tr id='vAmu0'><dt id='vAmu0'><q id='vAmu0'><span id='vAmu0'><b id='vAmu0'><form id='vAmu0'><ins id='vAmu0'></ins><ul id='vAmu0'></ul><sub id='vAmu0'></sub></form><legend id='vAmu0'></legend><bdo id='vAmu0'><pre id='vAmu0'><center id='vAmu0'></center></pre></bdo></b><th id='vAmu0'></th></span></q></dt></tr></i><div id='vAmu0'><tfoot id='vAmu0'></tfoot><dl id='vAmu0'><fieldset id='vAmu0'></fieldset></dl></div>

      <bdo id='vAmu0'></bdo><ul id='vAmu0'></ul>
    1. <legend id='vAmu0'><style id='vAmu0'><dir id='vAmu0'><q id='vAmu0'></q></dir></style></legend>

        <small id='vAmu0'></small><noframes id='vAmu0'>

        如何使用 Oracle 10 g Forms 发送电子邮件

        How to send email using Oracle 10 g Forms(如何使用 Oracle 10 g Forms 发送电子邮件)
          <bdo id='rIvlp'></bdo><ul id='rIvlp'></ul>
              <tbody id='rIvlp'></tbody>

              1. <i id='rIvlp'><tr id='rIvlp'><dt id='rIvlp'><q id='rIvlp'><span id='rIvlp'><b id='rIvlp'><form id='rIvlp'><ins id='rIvlp'></ins><ul id='rIvlp'></ul><sub id='rIvlp'></sub></form><legend id='rIvlp'></legend><bdo id='rIvlp'><pre id='rIvlp'><center id='rIvlp'></center></pre></bdo></b><th id='rIvlp'></th></span></q></dt></tr></i><div id='rIvlp'><tfoot id='rIvlp'></tfoot><dl id='rIvlp'><fieldset id='rIvlp'></fieldset></dl></div>
              2. <small id='rIvlp'></small><noframes id='rIvlp'>

                1. <tfoot id='rIvlp'></tfoot>

                  <legend id='rIvlp'><style id='rIvlp'><dir id='rIvlp'><q id='rIvlp'></q></dir></style></legend>
                  本文介绍了如何使用 Oracle 10 g Forms 发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我制作了一个我想要的表格,当我点击按钮时它会发送电子邮件我从互联网上获得电子邮件的代码

                  i make a form i want when i click on button it send email i get a code for email from internet

                      CREATE OR REPLACE FUNCTION FSC.SEND_MAIL
                  (pIssuer IN VARCHAR2,
                  pReceiver IN VARCHAR2,
                  pSender IN VARCHAR2,
                  pSubject IN VARCHAR2,
                  pMessage IN VARCHAR2) RETURN VARCHAR2 IS
                  
                  c utl_smtp.connection;
                  respuesta utl_smtp.reply;
                  pServer VARCHAR2(50) := '192.168.0.6';
                  
                  BEGIN
                  
                  -- Open the connection to the mail server
                  c := utl_smtp.open_connection(pServer);
                  respuesta := utl_smtp.helo(c, pServer);
                  
                  -- Start the Issuer mail.
                  respuesta := utl_smtp.mail(c, pSender);
                  
                  -- Starts Receiver
                  respuesta := utl_smtp.rcpt(c, pReceiver);
                  
                  respuesta := utl_smtp.open_data(c);
                  -- Enter the email header
                  utl_smtp.write_data(c, 'From: ' || pIssuer || utl_tcp.CRLF);
                  utl_smtp.write_data(c, 'To: ' || pReceiver || utl_tcp.CRLF);
                  -- Enter the Subject
                  utl_smtp.write_data(c, 'Subject: ' || pSubject || utl_tcp.CRLF);
                  -- Write the message text.
                  utl_smtp.write_data(c, utl_tcp.CRLF || pMessage);
                  utl_smtp.write_data(c, utl_tcp.CRLF || '.');
                  
                  respuesta := utl_smtp.close_data(c);
                  
                  -- Close connection
                  respuesta := utl_smtp.quit(c);
                  
                  RETURN '0';
                  
                  EXCEPTION
                  WHEN utl_smtp.transient_error OR utl_smtp.permanent_error THEN
                  utl_smtp.quit(c);
                  RETURN sqlerrm;
                  --raise_application_error(-20000,
                  -- 'The sending of the email has failed by returning the following error: ' || sqlerrm);
                  WHEN OTHERS THEN
                  RETURN sqlerrm;
                  END;
                  /
                  

                  我在 sql 中创建了这个函数并且它成功运行但是当我执行时没有电子邮件发送到我想要的地址

                  i make this function in sql it and it was successfully run but when i execute then no email send to my desire address

                  declare
                  
                  begin
                  
                  dbms_output.put_line(SEND_MAIL('usmanafb@ctm.com.pk','usmanafb@ctm.com.pk','usmanafb@ctm.com.pk','Testing','email message'));
                  end;
                  

                  我使用本地交换发送电子邮件,该服务器的 IP 地址为 192.168.0.6

                  i use my local exchange for eamil sending and the ip address of that server is 192.168.0.6

                  此代码中的第二个问题,当我在 Oracle 10 g 表单中创建相同的函数时,它给了我这个错误

                  the second issue in this code when i make same function in Oracle 10 g forms then it give me this error

                  utl_tcp.CRLF 是不能直接访问远程包

                  推荐答案

                  我使用这个通用程序来发送邮件.它还支持附件(仅限纯文本),邮件不限于 32767 个字符.

                  I use this general procedure to send out mails. It also supports attachment (plain text only) and mails are not limited to 32767 characters.

                  如果您根本不需要附件,删除它应该没有问题.

                  If you don't need attachments at all, it should be no problem for you to remove it.

                  PRIORITY_HIGH           CONSTANT INTEGER := 1;
                  PRIORITY_NORMAL         CONSTANT INTEGER := 3;
                  PRIORITY_LOW            CONSTANT INTEGER := 5;
                  
                  
                  PROCEDURE SendMail(
                      Subject IN VARCHAR2, 
                      Message IN OUT CLOB, 
                      ToMail IN VARCHAR2,   
                      FromMail IN VARCHAR2, FromName IN VARCHAR2,
                      Attachment IN OUT CLOB, FileName IN VARCHAR2,
                      Priority IN INTEGER DEFAULT PRIORITY_NORMAL) IS
                  
                      MIME_BOUNDARY   CONSTANT VARCHAR2(50) := '====Multipart.Boundary.689464861147414354====';
                      MIME_MIXED      CONSTANT VARCHAR2(50) := 'multipart/mixed;';
                      MIME_TEXT       CONSTANT VARCHAR2(50) := 'text/plain;';
                      MIME_HTML       CONSTANT VARCHAR2(50) := 'text/html;';  
                      MAIL_HOST       CONSTANT VARCHAR2(50) := '192.168.0.6'; -- try also 'mailhost'
                  
                      con UTL_SMTP.connection;
                      ret UTL_SMTP.reply;
                      Charset VARCHAR2(20);
                      Footer VARCHAR2(1000);
                  
                      ClobLen PLS_INTEGER;
                      amount BINARY_INTEGER := 8192;
                      buffer VARCHAR2(16384);
                      offset PLS_INTEGER := 1;
                      isHTML BOOLEAN := REGEXP_LIKE(DBMS_LOB.SUBSTR(Message, 1000, 1), '<(html)|(body)', 'i');
                  
                  BEGIN
                  
                      SELECT UTL_I18N.MAP_CHARSET(VALUE)
                      INTO Charset
                      FROM V$NLS_PARAMETERS
                      WHERE PARAMETER = 'NLS_CHARACTERSET';
                  
                      -- setup mail header
                      con := UTL_SMTP.OPEN_CONNECTION(MAIL_HOST, 25);
                      ret := UTL_SMTP.helo(con, SYS_CONTEXT('USERENV', 'DB_DOMAIN')); -- assuming your database is in the same domain as your mail server
                      ret := UTL_SMTP.Mail(con, FromMail);
                      ret := UTL_SMTP.rcpt(con, ToMail);
                      -- simply call "UTL_SMTP.rcpt(con, ...);" again in order to add further recipient
                      ret := UTL_SMTP.open_data(con);
                  
                      IF FromName IS NOT NULL THEN
                          UTL_SMTP.write_data(con, 'From: "'||FromName||'" <'||FromMail||'>'||Utl_Tcp.CRLF);
                      ELSE
                          UTL_SMTP.write_data(con, 'From: <'||FromMail||'>'||Utl_Tcp.CRLF);
                      END IF;
                      UTL_SMTP.write_data(con, 'To: <'||ToMail||'>'||Utl_Tcp.CRLF);
                      --  UTL_SMTP.write_data(con, 'Cc: <'||CcMail||'>'||Utl_Tcp.CRLF);       
                      UTL_SMTP.write_data(con, 'Subject: '||Subject||Utl_Tcp.CRLF);
                      UTL_SMTP.write_data(con, 'X-Priority: '||Priority||Utl_Tcp.CRLF);
                  
                      IF Attachment IS NOT NULL AND FileName IS NOT NULL THEN
                          UTL_SMTP.write_data(con, 'Mime-Version: 1.0' || Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, 'Content-Type: '||MIME_MIXED||' boundary="'||MIME_BOUNDARY||'"' || Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, 'This is a multipart message in MIME format.' || Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, '--'||MIME_BOUNDARY || Utl_Tcp.CRLF);
                      END IF;
                  
                      Footer := 'Message from '||SYS_CONTEXT('USERENV', 'DB_NAME')||' sent at '||TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss');
                      IF isHTML THEN
                          UTL_SMTP.write_data(con, 'Content-type: '||MIME_HTML||' charset='||Charset || Utl_Tcp.CRLF);
                          Message := REPLACE(message, '</body>', '<p>'||Footer||'</p></body>');
                      ELSE 
                          UTL_SMTP.write_data(con, 'Content-type: '||MIME_TEXT||' charset='||Charset || Utl_Tcp.CRLF);
                      END IF;
                  
                      -- Mail Body
                      UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                      ClobLen := DBMS_LOB.GETLENGTH(Message);
                      LOOP
                          EXIT WHEN offset > ClobLen;
                          DBMS_LOB.READ(Message, amount, offset, BUFFER);
                          UTL_SMTP.write_raw_data(con, UTL_RAW.cast_to_raw(BUFFER));
                          offset := offset + amount;
                      END LOOP;   
                      UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                      IF NOT isHTML THEN
                          UTL_SMTP.write_data(con, Utl_Tcp.CRLF || Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, Footer);
                          UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                      END IF;
                  
                      IF Attachment IS NOT NULL AND FileName IS NOT NULL THEN
                          -- Mail Attachment
                          UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, '--'||MIME_BOUNDARY || Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, 'Content-Type: '||MIME_TEXT||' name="'||Filename||'"'|| Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, 'Content-Disposition: attachment; filename="'||Filename||'"'|| Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                  
                          offset := 1;
                          ClobLen := DBMS_LOB.GETLENGTH(Attachment);
                          LOOP
                              EXIT WHEN offset > ClobLen;
                              DBMS_LOB.READ(Attachment, amount, offset, BUFFER);
                              UTL_SMTP.write_raw_data(con, Utl_Raw.cast_to_raw(BUFFER));
                              offset := offset + amount;
                          END LOOP;
                          UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                          UTL_SMTP.write_data(con, '--'||MIME_BOUNDARY||'--' || Utl_Tcp.CRLF);
                      END IF;
                  
                      -- finish mail
                      ret := UTL_SMTP.close_data(con);
                      ret := UTL_SMTP.quit(con);
                  
                  EXCEPTION
                      WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
                          UTL_SMTP.quit(con);
                          RAISE;
                  END SendMail;
                  

                  请注意,不要错过 UTL_SMTP.write_data(con, UTL_TCP.CRLF) 行.它们看起来是多余的,但大多数都是必需的!还有礼貌的消息,如这是 MIME 格式的多部分消息".需要在附件的情况下正确显示您的邮件.

                  Just a note, do not miss the UTL_SMTP.write_data(con, UTL_TCP.CRLF) lines. They are looking redundant, however most of them are required! Also courtesy message like "This is a multipart message in MIME format." is needed for proper display of your mail in case of attachments.

                  如果您仍然遇到问题,请在 UTL_SMTP 上的每个函数调用之后制作 dbms_output.put_line(ret.code||': '||ret.text);.

                  If you still face problems make a dbms_output.put_line(ret.code||': '||ret.text); after each function call on UTL_SMTP.

                  这里是相同的程序,但根据您的需要进行了简化:

                  Here the same procedure but reduced to your needs:

                  FUNCTION SendMail(
                      Subject IN VARCHAR2, 
                      Message IN VARCHAR2, 
                      FromMail IN VARCHAR2, FromName IN VARCHAR2, 
                      ToMail IN VARCHAR2) RETURN VARCHAR2 IS
                  
                      MIME_TEXT       CONSTANT VARCHAR2(50) := 'text/plain;';
                      MIME_HTML       CONSTANT VARCHAR2(50) := 'text/html;';  
                      MAIL_HOST       CONSTANT VARCHAR2(50) := '192.168.0.6'; -- try also 'mailhost'
                  
                      con UTL_SMTP.connection;
                      ret UTL_SMTP.reply;
                      Charset VARCHAR2(20);
                      isHTML BOOLEAN := REGEXP_LIKE(DBMS_LOB.SUBSTR(Message, 1000, 1), '<(html)|(body)', 'i');
                  
                  BEGIN
                  
                      SELECT UTL_I18N.MAP_CHARSET(VALUE)
                      INTO Charset
                      FROM V$NLS_PARAMETERS
                      WHERE PARAMETER = 'NLS_CHARACTERSET';
                  
                      -- setup mail header
                      con := UTL_SMTP.OPEN_CONNECTION(MAIL_HOST, 25);
                      ret := UTL_SMTP.helo(con, SYS_CONTEXT('USERENV', 'DB_DOMAIN')); -- assuming your database is in the same domain as your mail server
                      ret := UTL_SMTP.Mail(con, FromMail);
                      ret := UTL_SMTP.rcpt(con, ToMail);
                      ret := UTL_SMTP.open_data(con);
                  
                      UTL_SMTP.write_data(con, 'From: "'||FromName||'" <'||FromMail||'>'||Utl_Tcp.CRLF);
                      UTL_SMTP.write_data(con, 'To: <'||ToMail||'>'||Utl_Tcp.CRLF);
                      UTL_SMTP.write_data(con, 'Subject: '||Subject||Utl_Tcp.CRLF);
                      UTL_SMTP.write_data(con, 'X-Priority: 3'||Utl_Tcp.CRLF);
                  
                      IF isHTML THEN
                          UTL_SMTP.write_data(con, 'Content-type: '||MIME_HTML||' charset='||Charset || Utl_Tcp.CRLF);
                      ELSE 
                          UTL_SMTP.write_data(con, 'Content-type: '||MIME_TEXT||' charset='||Charset || Utl_Tcp.CRLF);
                      END IF;
                  
                      -- Mail Body
                      UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                      UTL_SMTP.write_raw_data(con, UTL_RAW.cast_to_raw(Message));
                      UTL_SMTP.write_data(con, Utl_Tcp.CRLF);
                  
                      -- finish mail
                      ret := UTL_SMTP.close_data(con);
                      ret := UTL_SMTP.quit(con);
                      RETURN '0';    
                  EXCEPTION
                      WHEN UTL_SMTP.TRANSIENT_ERROR OR UTL_SMTP.PERMANENT_ERROR THEN
                          UTL_SMTP.quit(con);
                          RETURN SQLERRM;
                  END SendMail;
                  

                  这篇关于如何使用 Oracle 10 g Forms 发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  Creating a flattened table/view of a hierarchically-defined set of data(创建分层定义的数据集的扁平表/视图)
                  MySQL: how to do row-level security (like Oracle#39;s Virtual Private Database)?(MySQL:如何做到行级安全(如 Oracle 的 Virtual Private Database)?)
                  What is the best way to enforce a #39;subset#39; relationship with integrity constraints(强制执行具有完整性约束的“子集关系的最佳方法是什么)
                  Split String by delimiter position using oracle SQL(使用 oracle SQL 按分隔符位置拆分字符串)
                  How to unfold the results of an Oracle query based on the value of a column(如何根据列的值展开Oracle查询的结果)
                  <i id='bLPhB'><tr id='bLPhB'><dt id='bLPhB'><q id='bLPhB'><span id='bLPhB'><b id='bLPhB'><form id='bLPhB'><ins id='bLPhB'></ins><ul id='bLPhB'></ul><sub id='bLPhB'></sub></form><legend id='bLPhB'></legend><bdo id='bLPhB'><pre id='bLPhB'><center id='bLPhB'></center></pre></bdo></b><th id='bLPhB'></th></span></q></dt></tr></i><div id='bLPhB'><tfoot id='bLPhB'></tfoot><dl id='bLPhB'><fieldset id='bLPhB'></fieldset></dl></div>

                          <tbody id='bLPhB'></tbody>
                          <bdo id='bLPhB'></bdo><ul id='bLPhB'></ul>
                          <legend id='bLPhB'><style id='bLPhB'><dir id='bLPhB'><q id='bLPhB'></q></dir></style></legend>

                          <small id='bLPhB'></small><noframes id='bLPhB'>

                          1. <tfoot id='bLPhB'></tfoot>