Chitika Add

Thursday, August 22

Mailing Program from plsql

DECLARE
  smtp_host       VARCHAR2 (256)          := 'smtp.hologic.com';
  SMTP_PORT       NUMBER                  := 25;
  boundary   CONSTANT VARCHAR2 (256) := 'CES.Boundary.DACA587499938898';
  FROM_RECIPIENTS VARCHAR2 (32767) := 'Jitin.indu@gmail.com';
  TO_RECIPIENTS   VARCHAR2 (32767) := 'jithendra.bavisetti@appsassociates.com';
  cc_recipients   VARCHAR2 (32767) := 'jkumar@hologic.com';
  crlf            VARCHAR2 (2) := CHR (13) || CHR (10);
  mesg            VARCHAR2 (32767);
  conn UTL_SMTP.connection;
  l_length NUMBER;
  l_sub    VARCHAR2 (32767);
  status   NUMBER :=0;
BEGIN
  conn := UTL_SMTP.open_connection (smtp_host, smtp_port);
  UTL_SMTP.HELO (CONN, SMTP_HOST);
  UTL_SMTP.mail (conn, from_recipients);
   UTL_SMTP.rcpt (conn, to_recipients);
   UTL_SMTP.rcpt (conn, cc_recipients);
   UTL_SMTP.OPEN_DATA (CONN);

  MESG := 'Date: ' || TO_CHAR (SYSDATE, 'Dy, dd Mon yyyy hh24:mi:ss')
          --|| CRLF || 'From: ' || FROM_RECIPIENTS
          || CRLF || 'Subject: ' || 'test mesg5 subject'
          --|| crlf || 'To: ' || to_recipients || crlf
          ;
  MESG := MESG || crlf || 'Content-Type: multipart/mixed; boundary="' || BOUNDARY || '"'
          || CRLF || CRLF || 'This is a Mime message, which your current mail reader may not'
          || CRLF || 'understand. Parts of the message will appear as text. If the remainder'
          || CRLF || 'appears as random characters in the message body, instead of as'
          || CRLF || 'attachments, then you''ll have to extract these parts and decode them'
          || crlf || 'manually.' || crlf || crlf;

  UTL_SMTP.write_data (conn, mesg);
  UTL_SMTP.close_data (conn);
  UTL_SMTP.quit (conn);
  STATUS := 1;
  dbms_output.put_line('status : '|| STATUS);
EXCEPTION
WHEN OTHERS THEN
  STATUS := 2;
  dbms_output.put_line('status : '||STATUS || sqlerrm);
END;