Home » Non-English Forums » Spanish » Envio de correo por medio del utl_smtp oracle forms (XE y Forms 6i)
Envio de correo por medio del utl_smtp oracle forms [message #476007] Mon, 20 September 2010 10:47
aguinav29
Messages: 28
Registered: August 2010
Location: CR
Junior Member

Buenas compaƱero... he estado intentado enviar un correo con un archivo adjunto desde forms, encontre la forma de hacerlo con el paquete utl_smtp pero resulta que este paquete me permite crear desde forms el archivo que quiero enviar, cual es la forma para poder elejir un archivo del disco duro y enviarlo como attach... Les adjunto mi codigo... de antemano muchas gracias por la ayuda!
PROCEDURE correo_2 IS
   v_From       VARCHAR2(80) := 'xxxxx@xxxxxxxx';
   v_Recipient  VARCHAR2(80) := 'xxxxx@xxxxxxxx';
   v_Subject    VARCHAR2(80) := 'PRUEBA';
   v_Mail_Host  VARCHAR2(30) := 'xxxxxxxxx.com';
   v_Mail_Conn  utl_smtp.Connection;
   crlf         VARCHAR2(2)  := chr(13)||chr(10);
BEGIN
  v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);

  utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);

  utl_smtp.Mail(v_Mail_Conn, v_From);

  utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);

  utl_smtp.Data(v_Mail_Conn,
    'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
    'From: '   || v_From || crlf ||
    'Subject: '|| v_Subject || crlf ||
    'To: '     || v_Recipient || crlf ||

    'MIME-Version: 1.0'|| crlf ||    -- Use MIME mail standard
    'Content-Type: multipart/mixed;'|| crlf ||
    ' boundary="-----SECBOUND"'|| crlf ||
    crlf ||

    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    'Content-Transfer_Encoding: 7bit'|| crlf ||
    crlf ||
    'some message text'|| crlf ||    -- Message body
    'more message text'|| crlf ||
    crlf ||

    '-------SECBOUND'|| crlf ||
    'Content-Type: text/plain;'|| crlf ||
    ' name="excel.csv"'|| crlf ||
    'Content-Transfer_Encoding: 8bit'|| crlf ||
    'Content-Disposition: attachment;'|| crlf ||
    ' filename="excel.csv"'|| crlf ||
    crlf ||
    'CSV,file,attachement'|| crlf ||    -- Content of attachment
    crlf ||

    '-------SECBOUND--'            -- End MIME mail
  );

  utl_smtp.Quit(v_mail_conn);
EXCEPTION
  WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
    --raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    null;
END;

Slds!!!
Previous Topic: Tipo de dato timestamp
Next Topic: Error Some database file locations are empty. Please specify locations for all database fi
Goto Forum:
  


Current Time: Thu Mar 28 07:49:51 CDT 2024