How to send a mail with HTML body from Oracle

Hi Team,
Can somebody guide me how to send a mail with HTML body from oracle.
Here is the piece of code i am trying to send a mail.
procedure SEND_MAIL is
cursor c_1 is select * from table_name;
l_mail_id varchar2(40);
-- ls_mailhost VARCHAR2(64) := Mailhost;
ls_from VARCHAR2(64) := ‘[email protected]
ls_subject VARCHAR2(200);
ls_to VARCHAR2(64);
l_mail_conn UTL_SMTP.connection;
ls_left_menu_name VARCHAR2(64);
ll_emp_num number(8);
begin
for i in c_1 loop
begin
l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
UTL_SMTP.HELO(l_mail_conn, 'IP');
UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
UTL_SMTP.RCPT(L_mail_conn, LS_TO);
UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
'To: ' ||ls_to || utl_tcp.crlf ||
'Subject: ' ||ls_subject|| utl_tcp.crlf);
UTL_SMTP.QUIT(l_mail_conn);
exception
when no_data_found then
null;
when others then
RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
end;
end loop;
end;
Thnx

Hi Nicolas!
Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
Hope this helps!
Regards
Geir

Similar Messages

  • How to send e-mail with an attachment from remote database server.???

    Hi All,
    I have tried the simple mail sending and with the attachment using UTL_SMTP. But the problem is , it is sending the mail with attachment of the file name i give, it takes and creates that file and sends as attachment not from the actual file location. I am trying to attach the file which i stored in remote database server.
    The following code I tried. But not worked for attachment
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'test subject';
       v_Mail_Host  VARCHAR2(30) := 'pop3.somedomain.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/html;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'some message text'|| crlf ||     -- Message body
        'more message text'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/html;'|| crlf ||
        ' name="Fund Authorization report"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="/usr/tmp/Test.html"'|| crlf ||
        crlf ||
        'HTML Attachment'|| 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);
    END;How can I attach a file which is stored in database server and send it in a mail.
    Please someone help me in this.
    Thanks,
    Alaka.

    Try this code
    Regards Salim.
    CREATE OR REPLACE TRIGGER EmailOnServerErr AFTER SERVERERROR ON DATABASE
    DECLARE
       mail_conn       UTL_SMTP.connection;
       crlf            VARCHAR2(2) := chr(13)||chr(10);
       msg             VARCHAR2(32760);
       sid_name        VARCHAR2(16);
       bdump_dest      VARCHAR2(128);
       smtp_relay      VARCHAR2(32) := 'MyMailRelay';
       recipient_address  VARCHAR2(64) := '[email protected]';
       sender_address     VARCHAR2(64) := '[email protected]';
       mail_port       NUMBER := 25;
       log_file_handle UTL_FILE.FILE_TYPE;
       log_file_dir    VARCHAR2(256) := 'ERR_LOG_DIR';
       log_file_name   VARCHAR2(256) := 'OracleErrors.log';
       maxlinesize     NUMBER := 32767;
       session_rec     sys.v_$session%ROWTYPE;
       audit_rec       sys.dba_audit_trail%ROWTYPE;
       auditing        BOOLEAN;
       LinesOfSQL      BINARY_INTEGER;
       offending_sql   DBMS_STANDARD.ora_name_list_t;
       CURSOR bdump_cur IS
          SELECT TRIM(value)
          FROM v$parameter
          WHERE name = 'background_dump_dest'
       CURSOR sid_cur IS
          SELECT TRIM(instance_name)
          FROM v$instance
       CURSOR session_cur IS
          SELECT s.*
          FROM v$session s
          WHERE s.sid = dbms_support.mysid
       CURSOR audit_trail_cur(AUDSID IN NUMBER) IS
          SELECT *
          FROM dba_audit_trail
          WHERE sessionid = AUDSID
    BEGIN
       IF (USER = 'SYSTEM' OR USER = 'SYS') THEN
          -- Ignore this error
          NULL;
       ELSIF IS_SERVERERROR (1034) THEN
          -- Ignore this error
          NULL;
       ELSE
          -- get the sid
          OPEN sid_cur;
          FETCH sid_cur INTO sid_name;
          CLOSE sid_cur;
          -- get the location of the alert log
          OPEN bdump_cur;
          FETCH bdump_cur INTO bdump_dest;
          CLOSE bdump_cur;
          -- get the session information
          OPEN session_cur;
          FETCH session_cur INTO session_rec;
          CLOSE session_cur;
          -- get the audit_trail information if it exists
          OPEN audit_trail_cur(session_rec.audsid);
          FETCH audit_trail_cur INTO audit_rec;
          auditing := audit_trail_cur%FOUND;
          CLOSE audit_trail_cur;
          IF session_rec.program = 'MyProgram.exe' THEN
             NULL;  -- ignore actions from MyProgram - that's where I do maintenance
          ELSE
             -- compose the message
             msg := 'Subject: Oracle error '||' on '||sid_name||crlf;
             msg := msg||'To: '||recipient_address||crlf;
             msg := msg||'For more information see the alert log file located at:'||crlf;
             msg := msg||bdump_dest||'/alert_'||sid_name||'.log'||crlf;
             msg := msg||'or the error log file: $'||log_file_dir||'/'||log_file_name||crlf;
             msg := msg||'Error Time='||TO_CHAR(SYSDATE,'DD-Mon-YYYY HH24:MI:SS')||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_CALL_STACK||crlf;
             LinesOfSQL := sql_txt(offending_sql);
             msg := msg||'Offending SQL is:'||crlf;
             FOR loop_counter IN offending_sql.FIRST..offending_sql.LAST
             LOOP
                msg := msg||offending_sql(loop_counter);
             END LOOP;
             msg := msg||crlf||'----- PL/SQL Error Stack -----'||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_ERROR_STACK||crlf;
             msg := msg||'V$SESSION.SADDR='   ||session_rec.saddr   ||crlf;
             msg := msg||'V$SESSION.SID='     ||session_rec.sid     ||crlf;
             msg := msg||'V$SESSION.SERIAL#=' ||session_rec.serial# ||crlf;
             msg := msg||'V$SESSION.AUDSID='  ||session_rec.audsid  ||crlf;
             msg := msg||'V$SESSION.PADDR='   ||session_rec.paddr   ||crlf;
             msg := msg||'V$SESSION.USER#='   ||session_rec.user#   ||crlf;
             msg := msg||'V$SESSION.USERNAME='||session_rec.username||crlf;
             msg := msg||'V$SESSION.COMMAND=' ||session_rec.command ||crlf;
             msg := msg||'V$SESSION.OWNERID=' ||session_rec.ownerid ||crlf;
             msg := msg||'V$SESSION.TADDR='   ||NVL(session_rec.taddr   ,'Null')||crlf;
             msg := msg||'V$SESSION.LOCKWAIT='||NVL(session_rec.lockwait,'Null')||crlf;
             msg := msg||'V$SESSION.STATUS='  ||NVL(session_rec.status  ,'Null')||crlf;
             msg := msg||'V$SESSION.SERVER='  ||NVL(session_rec.server  ,'Null')||crlf;
             msg := msg||'V$SESSION.SCHEMA#=' ||session_rec.schema#||crlf;
             msg := msg||'V$SESSION.SCHEMANAME=' ||NVL(session_rec.schemaname,'Null')||crlf;
             msg := msg||'V$SESSION.OSUSER='     ||NVL(session_rec.osuser    ,'Null')||crlf;
             msg := msg||'V$SESSION.PROCESS='    ||NVL(session_rec.process   ,'Null')||crlf;
             msg := msg||'V$SESSION.MACHINE='    ||NVL(session_rec.machine   ,'Null')||crlf;
             msg := msg||'V$SESSION.TERMINAL='   ||NVL(session_rec.terminal  ,'Null')||crlf;
             msg := msg||'V$SESSION.PROGRAM='    ||NVL(session_rec.program   ,'Null')||crlf;
             msg := msg||'V$SESSION.TYPE='       ||NVL(session_rec.type      ,'Null')||crlf;
             msg := msg||'V$SESSION.SQL_ADDRESS='    ||session_rec.sql_address  ||crlf;
             msg := msg||'V$SESSION.SQL_HASH_VALUE=' ||NVL(TO_CHAR(session_rec.sql_hash_value) ,'Null')||crlf;
             msg := msg||'V$SESSION.PREV_SQL_ADDR='  ||session_rec.prev_sql_addr||crlf;
             msg := msg||'V$SESSION.PREV_HASH_VALUE='||NVL(TO_CHAR(session_rec.prev_hash_value),'Null')||crlf;
             msg := msg||'V$SESSION.MODULE='     ||NVL(session_rec.module              ,'Null')||crlf;
             msg := msg||'V$SESSION.MODULE_HASH='||NVL(TO_CHAR(session_rec.module_hash),'Null')||crlf;
             msg := msg||'V$SESSION.ACTION='     ||NVL(session_rec.action              ,'Null')||crlf;
             msg := msg||'V$SESSION.ACTION_HASH='||NVL(TO_CHAR(session_rec.action_hash),'Null')||crlf;
             msg := msg||'V$SESSION.CLIENT_INFO='||NVL(session_rec.client_info         ,'Null')||crlf;
             msg := msg||'V$SESSION.FIXED_TABLE_SEQUENCE='||NVL(TO_CHAR(session_rec.fixed_table_sequence),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_OBJ#='  ||NVL(TO_CHAR(session_rec.row_wait_obj#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_FILE#=' ||NVL(TO_CHAR(session_rec.row_wait_file#) ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_BLOCK#='||NVL(TO_CHAR(session_rec.row_wait_block#),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_ROW#='  ||NVL(TO_CHAR(session_rec.row_wait_row#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.LOGON_TIME='     ||NVL(TO_CHAR(session_rec.logon_time,'DD-Mon-YYYY HH24:MI:SS'),'Null')||crlf;
             msg := msg||'V$SESSION.LAST_CALL_ET='   ||NVL(TO_CHAR(session_rec.last_call_et)   ,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_ENABLED='   ||NVL(session_rec.pdml_enabled   ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_TYPE='  ||NVL(session_rec.failover_type  ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_METHOD='||NVL(session_rec.failover_method,'Null')||crlf;
             msg := msg||'V$SESSION.FAILED_OVER='    ||NVL(session_rec.failed_over    ,'Null')||crlf;
             msg := msg||'V$SESSION.RESOURCE_CONSUMER_GROUP='||NVL(session_rec.resource_consumer_group,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_STATUS='    ||NVL(session_rec.pdml_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PDDL_STATUS='    ||NVL(session_rec.pddl_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PQ_STATUS='      ||NVL(session_rec.pq_status      ,'Null')||crlf;
             IF auditing THEN
                msg := msg||'DBA_AUDIT_TRAIL.OS_USERNAME='  ||NVL(audit_rec.os_username,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERNAME='     ||NVL(audit_rec.username   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERHOST='     ||NVL(audit_rec.userhost   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TERMINAL='     ||NVL(audit_rec.terminal   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TIMESTAMP='    ||TO_CHAR(audit_rec.timestamp,'DD-Mon-YYYY HH24:MI:SS')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OWNER='        ||NVL(audit_rec.owner      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_NAME='     ||NVL(audit_rec.obj_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION='       ||audit_rec.action   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION_NAME='  ||NVL(audit_rec.action_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_OWNER='    ||NVL(audit_rec.new_owner     ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_NAME='     ||NVL(audit_rec.new_name      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_PRIVILEGE='||NVL(audit_rec.obj_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SYS_PRIVILEGE='||NVL(audit_rec.sys_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ADMIN_OPTION=' ||NVL(audit_rec.admin_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.GRANTEE='      ||NVL(audit_rec.grantee       ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.AUDIT_OPTION=' ||NVL(audit_rec.audit_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SES_ACTIONS='  ||NVL(audit_rec.ses_actions   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_TIME='  ||NVL(TO_CHAR(audit_rec.logoff_time)  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LREAD=' ||NVL(TO_CHAR(audit_rec.logoff_lread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_PREAD=' ||NVL(TO_CHAR(audit_rec.logoff_pread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LWRITE='||NVL(TO_CHAR(audit_rec.logoff_lwrite),'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_DLOCK=' ||NVL(audit_rec.logoff_dlock  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.COMMENT_TEXT=' ||NVL(audit_rec.comment_text  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SESSIONID='    ||audit_rec.sessionid   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ENTRYID='      ||audit_rec.entryid     ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.STATEMENTID='  ||audit_rec.statementid ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.RETURNCODE='   ||audit_rec.returncode  ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.PRIV_USED='    ||NVL(audit_rec.priv_used,'Null')||crlf;
             END IF;
             msg := msg||'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'||crlf||crlf;
             -- write the message to the error log file
             log_file_handle := UTL_FILE.FOPEN (log_file_dir, log_file_name, 'A',maxlinesize);
             UTL_FILE.PUT_LINE(log_file_handle,msg);
             UTL_FILE.FCLOSE(log_file_handle);
             -- send the message by Email
             mail_conn := UTL_SMTP.open_connection(smtp_relay, mail_port);
             UTL_SMTP.HELO(mail_conn, smtp_relay);
             UTL_SMTP.MAIL(mail_conn, sender_address);
             UTL_SMTP.RCPT(mail_conn, recipient_address);
             UTL_SMTP.DATA(mail_conn, msg);
             UTL_SMTP.QUIT(mail_conn);
          END IF; -- client_program = MyProgram.exe
       END IF;
    END;
    /

  • How to send a mail in html format from a send mail workflow node ?

    Dear all,
    Do you know if it is possible to send an e-mail in HTML format (instead of RAW) from a "send mail" node in a workflow ?  ... if "yes", please, let me know.
    (I need to do that because I want to use the "href" tag to insert an hyperlink inside the e-mail)
    - I haven't found any parameter to specify the format of the e-mail.
    - Inside SCOT I tried to change the parameters for the SMTP node... without success.
    - I don't want to use a task calling the FM SO_OBJECT_SEND.
    Nicolas

    Hi Nicolas!
    Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
    If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
    SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
    Hope this helps!
    Regards
    Geir

  • How to send e-mail with attach file from a stated directory?

    I can only put the file in the program's same directory for attachment, how to state the file path for the file attachment?

    Hi..
    The FileDataSource class has two contructors.
    FileDataSource(java.io.File file)
    Creates a FileDataSource from a File object.
    FileDataSource(java.lang.String name)
    Creates a FileDataSource from the specified path name.
    Using either of them we can select the file in anypath of your system i.e. server.
    If you need relative path then you have to use File object.
    Cheers.

  • How to send a Mail purchase order automaticaly from ME22N

    How to send a Mail purchase order automaticaly from ME22N

    Hi,
    First create an entry via NACE with medium =   5 ( External send ) with all other details same as normal print option. Now ensure that vendor master of the po has got the external e-mail id of the vendor. Now go to ME22n in mesages create a message with medium = 5 ( External Send ). Go to communication method, key in Communication strategy.Go to Further date & against Despatch time pick up option 4 viz. Send immeidately while saving an application. Now once you press the save button it will be sent to the address maintained in the vendor master of the vendor of the PO. Please note you require some basic settings from BASIS side as well.
    I hope this helps,
    You may also refer to the SAP note 191470.
    Regards
    Raju Chitale

  • Send a mail with a picture from mime repository

    Hello,
    I want to send a mail with a picture from mime repository.
    The mail is sended OK, but the receiver hasn't  the picture on the mail  (don't find the picture).
    Here is my syntax :
       st_objtxt-line = '<IMG SRC="SAPR3://005056B2002D1EE3BF8F5B5ECDCA55E1" ALIGN=RIGHT WIDTH="100" HEIGHT="80">'.
        append st_objtxt to t_objtxt.
    "SAPR3://005056B2002D1EE3BF8F5B5ECDCA55E1" is url of my object mime .
    Have you a idea to resolve this problem ? It's the syntax OK ?
    Thank for your responses.
    Regards.
    JCAIL

    Have you tried storing your picture as a business document?  Have a look at the class  cl_bds_document_set to read your picture from the BDS.

  • How to send a mail with rich text content like using outlook

    Hi All. I have a serious problem. When we send the mail from
    outlook express or yahoo, we can send the mail with the text appearing
    in the mail with bold font , with different colors, underlined etc.
    If i type this kind of text in any word processor and mail that content through java mail then the message should be received by the recepient with all that bold,color and underlines etc as it is. Can anybody please help me in this case ASAP.

    Go to this site and download the htmlArea Javascripts. Embedd them in your HTML and it will turn your normal HTML Text Area into Rich Text Area. Your real code will include all HTML tags. For example if you select some text and make it bold , the real HTML output will look like <B>YOUR TEXT </B>. So i guess your recipient should be able to receive HTML contents.
    http://www.interactivetools.com/products/htmlarea/

  • How to send a mail with attaching a report

    hi gurus,
        my requirment is i have to send a mail with attaching the report of a program to the client.. is it possible? help me with sample code.
    Thanks in advance.
    Regards,
    Indira D

    Hi Indira,
    plz check out this code below,
    *& Report  ZATTACH                                               *
    REPORT  ZATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.
    " POPULATE_EMAIL_MESSAGE_BODY
    <b>
    Reward points if this helps,</b>
    Kiran

  • How to send a mail with PDF attachment

    Hello
    Good Day!
    We have a requirement to send the mail with pdf attachment. Pdf file will be remain same for all mails and it will be placed at server. We are on R12.4 and below is the database information :
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    Thanks a ton for your anticipated help!
    Thanks
    Gaurav

    The word URGENT is considered as rude in this forum.. Nobody here is getting paid for the ansers they are giving..
    Just have a look at These threads.Those will help you.

  • How to send e-mails with attachments using microsoft exchange servers?

    I was wondering if there was a way to send e-mails with attached data files.  The e-mail server utilizes a Microsoft Exchange Server.  I would appreciate any help that is provided.

    What version and type of development system of LabVIEW do you have. You have the SMTP Email Send File and SMTP Email Send Multiple Attachments in all except the base package.

  • How to send a mail to a person  from after completeing bdc .

    Hi Xperts,
    Please send me a options how to send a mail to a person after completing a bdc or from any report program.
    mailed can be a sapuser or other service provider(ex:yahoo,gmail.any thing)
    Please Any one i want it now .
    Thank You.

    FUNCTION RS_SEND_MAIL_FOR_SPOO* Email ITAB structure
    DATA: BEGIN OF EMAIL_ITAB OCCURS 10.
            INCLUDE STRUCTURE SOLI.
    DATA: END OF EMAIL_ITAB.
    DATA: T_EMAIL LIKE SOOS1-RECEXTNAM.  "EMail distribution list
    CONSTANTS: C_EMAIL_DISTRIBUTION LIKE SOOS1-RECEXTNAM VALUE
               ‘[email protected],[email protected]’.
    Initialization
    REFRESH EMAIL_ITAB.
    Populate data
    EMAIL_ITAB-LINE = ‘Email body text 1’.
    APPEND EMAIL_ITAB.
    EMAIL_ITAB-LINE = ‘Email body text 2’.
    APPEND EMAIL_ITAB.
    T_EMAIL = C_EMAIL_DISTRIBUTION.
    --- EMAIL FUNCTION ---------------------------------------------------
    REQUIRMENTS:
    1) The user running the program needs a valid email address in their
       address portion of tx SU01 under external comms -> SMTP -> internet
       address.
    2) A job called SAP_EMAIL is running with the following parameters:
       Program: RSCONN01  Variant: INT   User: XXX
       This program moves mail from the outbox to the mail server using
       RFC destination: SAP_INTERNET_GATEWAY_SERVER
    INTERFACE:
    1) APPLICATION: Anything
    2) EMAILTITLE:  EMail subject
    3) RECEXTNAM:   EMail distribution lists separated by commas
    4) TEXTTAB:     Internal table for lines of the email message
    EXCEPTIONS:
    Send OK = 0 otherwise there was a problem with the send.
        CALL FUNCTION 'Z_SEND_EMAIL_ITAB'
             EXPORTING
                  APPLICATION = 'EMAIL'
                  EMAILTITLE  = 'Email Subject'
                  RECEXTNAM   = T_EMAIL
             TABLES
                  TEXTTAB     = EMAIL_ITAB
             EXCEPTIONS
                  OTHERS      = 1.
    Function Z_SEND_EMAIL_ITAB
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(APPLICATION) LIKE  SOOD1-OBJNAM
    *"             VALUE(EMAILTITLE) LIKE  SOOD1-OBJDES
    *"             VALUE(RECEXTNAM) LIKE  SOOS1-RECEXTNAM
    *"       TABLES
    *"              TEXTTAB STRUCTURE  SOLI
    *- local data declaration
      DATA: OHD    LIKE SOOD1,
            OID    LIKE SOODK,
            TO_ALL LIKE SONV-FLAG,
            OKEY   LIKE SWOTOBJID-OBJKEY.
      DATA: BEGIN OF RECEIVERS OCCURS 0.
              INCLUDE STRUCTURE SOOS1.
      DATA: END OF RECEIVERS.
    *- fill odh
      CLEAR OHD.
      OHD-OBJLA    = SY-LANGU.
      OHD-OBJNAM   = APPLICATION.
      OHD-OBJDES   = EMAILTITLE.
      OHD-OBJPRI   = 3.
      OHD-OBJSNS   = 'F'.
      OHD-OWNNAM   = SY-UNAME.
    *- send Email
      CONDENSE RECEXTNAM NO-GAPS.
      CHECK RECEXTNAM <> SPACE AND RECEXTNAM CS '@'.
    *- for every individual recipient send an Email
    (see OSS message 0120050409/0000362105/1999)
      WHILE RECEXTNAM CS ','.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM+0(SY-FDPOS).
        ADD 1 TO SY-FDPOS.
        SHIFT RECEXTNAM LEFT BY SY-FDPOS PLACES.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDWHILE.
    *- check last recipient in recipient list
      IF RECEXTNAM <> SPACE.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDIF.
    ENDFUNCTION.
          FORM SO_OBJECT_SEND_REC                                       *
    FORM  SO_OBJECT_SEND_REC
    TABLES  OBJCONT      STRUCTURE SOLI
            RECEIVERS    STRUCTURE SOOS1
    USING   OBJECT_HD    STRUCTURE SOOD1.
      DATA:   OID     LIKE SOODK,
              TO_ALL  LIKE SONV-FLAG,
              OKEY    LIKE SWOTOBJID-OBJKEY.
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                EXTERN_ADDRESS             = 'X'
                OBJECT_HD_CHANGE           = OBJECT_HD
                OBJECT_TYPE                = 'RAW'
                OUTBOX_FLAG                = 'X'
                SENDER                     = SY-UNAME
           IMPORTING
                OBJECT_ID_NEW              = OID
                SENT_TO_ALL                = TO_ALL
                OFFICE_OBJECT_KEY          = OKEY
           TABLES
                OBJCONT                    = OBJCONT
                RECEIVERS                  = RECEIVERS
           EXCEPTIONS
                ACTIVE_USER_NOT_EXIST      = 1
                COMMUNICATION_FAILURE      = 2
                COMPONENT_NOT_AVAILABLE    = 3
                FOLDER_NOT_EXIST           = 4
                FOLDER_NO_AUTHORIZATION    = 5
                FORWARDER_NOT_EXIST        = 6
                NOTE_NOT_EXIST             = 7
                OBJECT_NOT_EXIST           = 8
                OBJECT_NOT_SENT            = 9
                OBJECT_NO_AUTHORIZATION    = 10
                OBJECT_TYPE_NOT_EXIST      = 11
                OPERATION_NO_AUTHORIZATION = 12
                OWNER_NOT_EXIST            = 13
                PARAMETER_ERROR            = 14
                SUBSTITUTE_NOT_ACTIVE      = 15
                SUBSTITUTE_NOT_DEFINED     = 16
                SYSTEM_FAILURE             = 17
                TOO_MUCH_RECEIVERS         = 18
                USER_NOT_EXIST             = 19
                X_ERROR                    = 20
                OTHERS                     = 21.
      IF SY-SUBRC <> 0.
        RAISE OTHERS.
      ENDIF.
    ENDFORM.
          FORM INIT_REC                                                 *
    FORM INIT_REC TABLES RECEIVERS STRUCTURE SOOS1.
      CLEAR RECEIVERS.
      REFRESH RECEIVERS.
      MOVE SY-DATUM  TO RECEIVERS-RCDAT .
      MOVE SY-UZEIT  TO RECEIVERS-RCTIM.
      MOVE '1'       TO RECEIVERS-SNDPRI.
      MOVE 'X'       TO RECEIVERS-SNDEX.
      MOVE 'U-'      TO RECEIVERS-RECNAM.
      MOVE 'U'       TO RECEIVERS-RECESC.
      MOVE 'INT'     TO RECEIVERS-SNDART.
      MOVE '5'       TO RECEIVERS-SORTCLASS.
      APPEND RECEIVERS.
    ENDFORM.
    2.

  • Mail with HTML BODY content?

    Hi,
    We seem to have a little problem with sending mails wtih HTML content, we have a "Link" in the mail body to be sent , so we are using html tags <a href=""link"></a> so that the mail receipient see the URL as a link ....
    The actual code used is given below:-
    l_body_html := ' <html>
    <body>
    <p>Hi,<br><br>You have been provided access to <a href="http://URL.com:20000/pls/htmldb/f?p=102"></a>'||
    '</p> </body> </html>'
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => '[email protected]',
    P_BODY => l_body_html,
    P_BODY_HTML => l_body_html,
    P_SUBJ => 'Access Details.');
    What is wrong here , except the link of URL the rest of the text is coming in the mail body...
    regards
    Naveen

    Naveen,
    This is an HTML problem. You have provided no text for the anchor.
    You probably want something like:
    &lt;a href=http://URL.com:20000/pls/htmldb/f?p=102>Click Here&lt;/a>
    And to be proper HTML, you should enclose the href value in double quotes, as in:
    &lt;a href="http://URL.com:20000/pls/htmldb/f?p=102">Click Here&lt;/a>
    Joel

  • How to send Java mail with attachment?

    Could you please provide the sample codes using the javax.mail api for sending an email with an attachment?

    this is code
    zareen abbas
    <html><body><center>
    <FORM ACTION="/servlet/Attach" method="post">
    <!--I didn,t used this ENCTYPE-->
    <!--ENCTYPE="multipart/form-data" -->
    <table border=0 bgcolor background="#00000">
    <tr><td><font size=4> <b>From: </b> </font> </td>
    <td><input type=text name=from size=40></td></tr>
    <tr><td><font size=4> <b>To : </b> </font> </td>
    <td><input type=text name=to size=40> </td></tr>
    <tr><td><font size=4> <b>CC : </b> </font> </td>
    <td><input type=text name=cc size=40> </td></tr>
    <tr><td><font size=4> <b>BCC : </b> </font> </td>
    <td><input type=text name=bcc size=40> </td></tr>
    <tr><td><font size=4> <b>Subject : </b> </font> </td>
    <td><input type=text name=subject size=40> </td></tr>
    <tr><td><font size=4> <b>Body : </b> </font> </td>
    <td><textarea name=body rows=15 cols=40> </textarea> </td></tr>
    </table>
    <p>Select a file:<input type=file name=attach>
    <input type=submit value="send">
    <input type=reset name=reset1
    value="Clear"></Form></center></body></html>
    here the servlet code
    File file = new File(filename);
    if (file.exists())
    MimeBodyPart mbp1 = new MimeBodyPart();
    mbp1.setText(text);
    MimeBodyPart mbp2 = new MimeBodyPart();
    FileDataSource fds = new FileDataSource(filename);
    mbp2.setDataHandler(new DataHandler(fds));
    mbp2.setFileName(fds.getName());
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp1);
    mp.addBodyPart(mbp2);
    message.setContent(mp);
    else
    message.setText(text);
    Transport.send(message);

  • How to Send E-mail With Attachments

    <Sorry, if this is in the wrong forum>
    I want to be able to send e-mails from a procedure having attached a file which is retrieved from a BLOB.
    I found Note:120994.1 on Metalink. This note describes how to do this with Sun's JavaMail and a Java Stored Procedures. Unfortunately, it takes the attachment from the file system of the OS, not from a BLOB.
    Has anyone adapted this JSP to retrieve attachment from a BLOB? Is it possible? Maybe it is easy, but unfortunately I don't have experience with Java.
    Or has anyone another approach for this task?

    You can create a link that sends an email message (mailto:)
    http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Article s/MailLinks.html#//apple_ref/doc/uid/TP40007892-SW1

  • Send a mail with a body and attachment

    Hi guys!!!!
    I have a RFC -> XI -> Mail Scenario!
    I'm able to send text in the body of the mail. I'm able to send text as an attachment. But I'd like to send both (text in the body and other text as an attachment). How can I do this?
    thanks in advance
    Julio

    First, I'd like to thank all the replies! And Jagesh, I solved my problem reading the thread you told me.
    I created a message as follow:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
         <Subject>test</Subject>
         <From>test_source @ abc.com</From>
         <To>test_target @ abc.com</To>
         <Content_Type>multipart/mixed; boundary="AaBb--984dfgeSSd3532"</Content_Type>
         <Content>*AaBb984dfgeSSd3532*
    Content-Type: text/plain
    Hello, this is sample data.
    *AaBb984dfgeSSd3532*
    Content-Type: text/plain;name="CSV_data.csv"
    abc
    </Content>
    </ns:Mail>
    In addittion to this, I configured Mail channel as follow:
    Content encondig = none
    Keep Attachments = false

Maybe you are looking for