Sending an Excel Attachment in E-mail, where linesize 255 characters

Hi,
I have a requirement where I need to send an Excel attachment of around 150 columns and the line-size is around 2000 characters.
I was planning to use SO_DOCUMENT_SEND_API1.
But, it appears that because of the restriction of 255 characters as SOLISTI1 structure has the field size of 255 characters.
Please note, I cannot use any of the OLE or foreground Excel functions, as the job runs in the background.
Please let me know if you have any solutions or work around.
Hoiping to hear from all of the experts out there.
Regards,
Ani

try to use the following classes :       
send_request  TYPE REF TO cl_bcs,
        document      TYPE REF TO cl_document_bcs,
        conlengths    TYPE        so_obj_len,
        html          TYPE STANDARD TABLE OF w3html,
        sender_id     TYPE REF TO if_sender_bcs,
        recipient     TYPE REF TO if_recipient_bcs,
        sent_to_all   TYPE        os_boolean,
        bcs_exception TYPE REF TO cx_bcs,
        bcs_message   TYPE        string.

Similar Messages

  • Send an Excel Attachment as mail to a list of recipients

    Hello Everyone,
    I am trying to send an email with an excel attachment. My code has been activated successfully. But I haven't received any mail.
    Kindly help.
    My code is as below.
    FORM Z_SENDMAIL .
      DATA lv_receiver type SOMLRECI1-RECEIVER.
      TYPES: BEGIN OF LTS_CHARFINAL,
        matnr(18) type c,
        maktx(40) type c,
        idnlf(35) type c,
        ltsnr(6) type c,
        werks(4) type c,
        ltsbz(20) type c,
        ernam(12) type c,
        verpr(11) type c,
        soh_qty(13) TYPE c,
        int_qty(13) TYPE c,
        ext_soh(11) TYPE c,
        hol_qty(13) TYPE c,
        all_qty(13) TYPE c,
        bac_qty(13) TYPE c,
        ext_ttl(11) TYPE c,
        END OF LTS_CHARFINAL.
      DATA: WA_CHARFINAL TYPE LTS_CHARFINAL.
      lv_receiver = '[email protected]'.
      CONCATENATE 'ITEM_TRIM'
                  'DESCRIPTION'
                  'VEND_ITEM'
                  'PLNRCODE'
                  'LOCATION'
                  'SITE'
                  'PLANNER'
                  'AVERAGE_COST'
                  'SOH_QTY'
                  'INTRANS_QTY'
                  'EXT_COST_SOH'
                  'HOLD_QTY'
                  'ALLOC_QTY'
                  'BACKORD_QTY'
                  'EXT_COST_TTL_INVEN'
             INTO IT_ATTACH SEPARATED BY CON_TAB.
      CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
      APPEND  IT_ATTACH.
      LOOP AT GIT_FINAL INTO GWA_FINAL.
        wa_charfinal-matnr = gwa_final-matnr.
        wa_charfinal-maktx = gwa_final-maktx.
        wa_charfinal-idnlf = gwa_final-idnlf.
        wa_charfinal-ltsnr = gwa_final-ltsnr.
        wa_charfinal-werks = gwa_final-werks.
        wa_charfinal-ltsbz = gwa_final-ltsbz.
        wa_charfinal-ernam = gwa_final-ernam.
        wa_charfinal-verpr = gwa_final-verpr.
        wa_charfinal-soh_qty = gwa_final-soh_qty.
        wa_charfinal-int_qty = gwa_final-int_qty.
        wa_charfinal-ext_soh = gwa_final-ext_soh.
        wa_charfinal-hol_qty = gwa_final-hol_qty.
        wa_charfinal-all_qty = gwa_final-all_qty.
        wa_charfinal-bac_qty = gwa_final-bac_qty.
        wa_charfinal-ext_ttl = gwa_final-ext_ttl.
        CONCATENATE wa_charfinal-matnr
                    wa_charfinal-maktx
                    wa_charfinal-idnlf
                    wa_charfinal-ltsnr
                    wa_charfinal-werks
                    wa_charfinal-ltsbz
                    wa_charfinal-ernam
                    wa_charfinal-verpr
                    wa_charfinal-soh_qty
                    wa_charfinal-int_qty
                    wa_charfinal-ext_soh
                    wa_charfinal-hol_qty
                    wa_charfinal-all_qty
                    wa_charfinal-bac_qty
                    wa_charfinal-ext_ttl
               INTO IT_ATTACH SEPARATED BY CON_TAB.
        CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
        APPEND  IT_ATTACH.
      ENDLOOP.
        PERFORM Z_BUILD_MESSAGE.
        PERFORM Z_SEND_FILE_ATTACHMENT
                                   TABLES IT_MESSAGE
                                          IT_ATTACH
                                    USING lv_receiver
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 CHANGING GD_ERROR
                                          GD_RECIEVER.
    ENDFORM.
    FORM Z_BUILD_MESSAGE .
      REFRESH IT_MESSAGE.
      IT_MESSAGE = 'Please find the attached document'.
      APPEND IT_MESSAGE.
    ENDFORM.                    " Z_BUILD_MESSAGE
    FORM Z_SEND_FILE_ATTACHMENT  TABLES   P_IT_MESSAGE
                                          P_IT_ATTACH STRUCTURE IT_ATTACH
                                 USING    P_lv_receiver
                                          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_LV_RECEIVER.
      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[] = P_IT_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.                    " Z_SEND_FILE_ATTACHMENT
    -Regards
    Monica

    Hi Monica,
    Please check with your BASIS team if all the required configurations are there to send mail.
    You can check in SOST transaction if you have an entry there for your mail.
    Another relevant transaction in SCOT.
    Regards,
    Santanu.

  • Sending Excel attachment in E-mail

    Hi All,
    I am sending excel attachment in mail, when I see in SO01 tcode I am able to see the attachment in outbox, but getting 'Error during send Process' in sent status and not getting any mails to my e-mail id.
    Could you any one help me in this?
    Thanks in advance.
    Vijaya.

    Hi,
    data: p_email   type somlreci1-receiver
                          value 'Mail ID'.
    data: begin of it001 occurs 0,
          bukrs type t001-bukrs,
          butxt type t001-butxt,
          end of it001.
    data:   imessage type standard table of solisti1 with header line,
            iattach type standard table of solisti1 with header line,
            ipacking_list like sopcklsti1 occurs 0 with header line,
            ireceivers like somlreci1 occurs 0 with header line,
            iattachment like solisti1 occurs 0 with header line.
    start-of-selection.
      select bukrs butxt into table it001 from t001.
      Populate table with detaisl to be entered into .xls file
      perform build_xls_data .
    Populate message body text
      clear imessage.   refresh imessage.
      imessage = 'Please find attached excel file'.
      append imessage.
    Send file by email as .xls speadsheet
      perform send_email_with_xls tables imessage
                                          iattach
                                    using p_email
                                          'Example Excel Attachment'
                                          'XLS'
                                          'TestFileName'
                                          'CompanyCodes'.
         Form  BUILD_XLS_DATA
    form build_xls_data .
    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 'BUKRS' 'BUTXT'
             into iattach separated by con_tab.
      concatenate con_cret iattach into iattach.
      append  iattach.
      loop at it001 .
        concatenate it001-bukrs it001-butxt
               into iattach separated by con_tab.
        concatenate con_cret iattach  into iattach.
        append  iattach.
      endloop .
    endform.
         Form  SEND_EMAIL_WITH_XLS
    form send_email_with_xls tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription.
      data: xdocdata like sodocchgi1,
            xcnt type i.
    Fill the document data.
      xdocdata-doc_size = 1.
    Populate the subject/generic message attributes
      xdocdata-obj_langu = sy-langu .
      xdocdata-obj_name  = 'SAPRPT' .
      xdocdata-obj_descr = p_mtitle .
    Fill the document data and get size of attachment
      clear xdocdata.
      read table iattach index xcnt.
      xdocdata-doc_size =
         ( xcnt - 1 ) * 255 + strlen( iattach ).
      xdocdata-obj_langu  = sy-langu.
      xdocdata-obj_name   = 'SAPRPT'.
      xdocdata-obj_descr  = p_mtitle.
      clear iattachment.  refresh iattachment.
      iattachment[] = pit_attach[].
    Describe the body of the message
      clear ipacking_list.  refresh ipacking_list.
      ipacking_list-transf_bin = space.
      ipacking_list-head_start = 1.
      ipacking_list-head_num = 0.
      ipacking_list-body_start = 1.
      describe table imessage lines ipacking_list-body_num.
      ipacking_list-doc_type = 'RAW'.
      append ipacking_list.
    Create attachment notification
      ipacking_list-transf_bin = 'X'.
      ipacking_list-head_start = 1.
      ipacking_list-head_num   = 1.
      ipacking_list-body_start = 1.
      describe table iattachment lines ipacking_list-body_num.
      ipacking_list-doc_type   =  p_format.
      ipacking_list-obj_descr  =  p_attdescription.
      ipacking_list-obj_name   =  p_filename.
      ipacking_list-doc_size   =  ipacking_list-body_num * 255.
      append ipacking_list.
    Add the recipients email address
      clear ireceivers.  refresh ireceivers.
      ireceivers-receiver = p_email.
      ireceivers-rec_type = 'U'.
      ireceivers-com_type = 'INT'.
      ireceivers-notif_del = 'X'.
      ireceivers-notif_ndel = 'X'.
      append ireceivers.
      call function 'SO_DOCUMENT_SEND_API1'
           exporting
                document_data              = xdocdata
                put_in_outbox              = 'X'
                commit_work                = 'X'
           tables
                packing_list               = ipacking_list
                contents_bin               = iattachment
                contents_txt               = imessage
                receivers                  = ireceivers
           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.
    endform.
    Check this Sample code.
    Thanks,
    Durai.V

  • Excel Attachment Problem in Mail box

    Hi All,
    I had program in which i am sending mail along with Excel attachment using FM SO_DOCUMENT_ATT_SEND_API1. Mail is going fine with data in Excel attachment. But when i try to open the Excel it gives an Info message saying that "You are trying to open (attachment name),is in different format than specified file extension Verify that file is not corrupted and is from a trusted source before opening file. Do you want to open file now". Then when i presses YES, Excel opens up with all data. I want to know how to avoid that info popup. Is there something has to be passed to FM or something has to be done to Excel like settings in EXCEL so that i can avoid that Info message coming.
    Document type of attachment is gw_packing_list-doc_type = 'XLS'.
    Can someone help me on this ?
    Thanks,
    Praveen

    Hi,
    With the Module , you can check this-
    Hope this link may help you-
    Body and Attachment both in a mail
    Idoc to a flatfile and then email it as an attachment
    Regards,
    Moorthy

  • Excel Attachment in E-mail

    Hi,
    My requiremnt is to attach an excel file in the e-mail which will be triggered through an output type while saving the RFQ document.
    This excel attachment will have the item details. And some of the columns in the excel attachment needs to be protected(Non editable mode) and the structure also be protected
    Please help me out in this.

    this is a simple example for sending the excel with attachment..
    REPORT  ZMAIL.
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver .
    (here give the email id)
    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.
      data: ld_store(50) type c.  "Leading zeros
      CONSTANTS: con_cret(5) TYPE c VALUE '0D',  "OK for non Unicode
                 con_tab(5) TYPE c 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.
    *Modification to retain leading zeros
      inserts code for excell REPLACE command into ld_store
      =REPLACE("00100",1,5,"00100")
        concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
                                 wa_charekpo-ebelp '")' into ld_store .
      concatenate ld_store into .xls file instead of actual value(ebelp)
        CONCATENATE wa_charekpo-ebeln ld_store  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
    regards,
    venkat

  • Sending PDF output attachment in e-mail to external users from BSP

    Hi All,
    Please gothrough the below requirement details :
    Requirement Details:
    Need to achieve the functionality of sending a PDF attachment of invoice to an external
    e-mail address from the BSP Application.
    Implementation Details:
    The Print out Output determination is already done in the system. We are using SAP R/3 4.7 (620)
    In the Transaction VF03 in the initial screen there is a menubar "Billing document" and underneath that menu there is a menu item called "Issue". If we click the "Issue" menu item all the output that are already proposed will be visible and we can select the printout Output determination and can issue a printout.
    I had created a FM to call from BSP and that function module will take the Invoice number as input and will call the "VF03" transaction using BDC and will trigger the Sapscript Printout . I see the the sapscript in the spool after I call the Function module .
    But I don't know how I can get the Spool request number for that Function module call from BSP page ????
    I got struck in this approach...
    If I know the Spool number after calling the function module the it's very easy to call the following FM's for sending a e-mail with the Invoice PDF attachment.
    CONVERT_OTFSPOOLJOB_2_PDF
    QCE1_CONVERT
    SO_NEW_DOCUMENT_ATT_SEND_API1
    Please let me know if anyone can help me in this ...
    Please reply ASAP.
    Thanks,
    Greetson

    Check out these weblogs.
    /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    Regards
    Raja

  • Excel attachment in a mail for background program

    Hi,
    I have a program which is scheduled to execute in background every day.
    Program output is printed to the screen. Simultaneously, I want to send an excel file as an attachment through email.
    This excel file would be having the same data which is printed on the screen.
    I have checked for other threads  in SDN for sending excel file as attachment, but did not find anything relavant.
    If anyone has any idea, please let me know....
    Thanks in advance - S M

    Hi,
    You can use the cl_bcs class to send email with attachments.
    Refer to the below article of mine which has the code snippet on how to send an excel file as an attachement.
    http://divulgesap.com/blog.php?p=ODI=
    Hope it helps.
    Regards,
    Ravikiran

  • Send a file attached to a mail send with sendmail

    Hello,
    I'd like to send a report with a short mail to a mailing list. This task will be done every day by executing a ksh script.
    May I do it with sendmail ? how ?
    Is there another way to do it ?
    Thanks for your help.
    Ncg

    Sorry,
    question already posted on kernel Forum: "Command line mail - attachment"

  • Error during sending a PDF attachment of a mail

    Hi everebody,
                      I'm using a custom program [ see below ] ( in which there is the call to the std function SO_DOCUMENT_SEND_API1) to send a PDF attachment to an user's SAPOFFICE: in release 4.6C it works correctly but the same programm in ECC6 it doesn't work correctly.  I mean: the mail is sent correctly with the attachment, but when I try to open the attachment this one doesn't open correctly showing a PDF error message.
    Any help?
                gino bonfiglioli
    *& Report  Z_UT_CONVERT_SPOOL_PDF
    REPORT  z_ut_convert_spool_pdf.
    TABLES: tsp01.
    variabili globali
    *data: fm_name            type rs38l_fnam,
         output_options     type ssfcompop,
         control_parameters type ssfctrlop,
         job_output_info    type ssfcrescl,
         job_output_options type ssfcresop,
    DATA: spoolno            LIKE tsp01-rqident,
          dir_pdf            LIKE rlgrap-filename,
          numbytes           TYPE i,
          pagecount          TYPE i,
          w_cnt              TYPE i,
          wk_subrc           LIKE sy-subrc,
          pdfspoolid         LIKE tsp01-rqident,
          gd_buffer          TYPE string,
          pdf                LIKE tline OCCURS 100 WITH HEADER LINE,
          stampante          LIKE usr01-spld,
          tot_line   TYPE sy-tabix,
          tot_line2  TYPE sy-tabix,
          start_line TYPE sy-tabix.
    tabelle interne per 1a mail
    DATA: BEGIN OF it_email OCCURS 100.
            INCLUDE STRUCTURE solisti1.
    DATA: END OF it_email.
    DATA: BEGIN OF email_data.
            INCLUDE STRUCTURE sodocchgi1.
    DATA: END OF email_data.
    DATA: BEGIN OF email_send OCCURS 10.
            INCLUDE STRUCTURE somlreci1.
    DATA: END OF email_send.
    DATA: packing_list TYPE STANDARD TABLE OF sopcklsti1 WITH HEADER LINE,
          it_mess_att  LIKE solisti1 OCCURS 0 WITH HEADER LINE,
          receivers    TYPE STANDARD TABLE OF somlreci1 WITH HEADER LINE.
    fine tabelle interne per 1a mail
    PARAMETER: p_spool LIKE tsp01-rqident.
    START-OF-SELECTION.
      PERFORM conversione_spool_pdf USING wk_subrc.
      IF wk_subrc EQ 0.
        PERFORM invio_mail.
      ENDIF.
    *&      Form  CONVERSIONE_SPOOL_PDF
          text
         -->P_P_SUBRC  text
    FORM conversione_spool_pdf  USING    p_subrc.
    **- Conversione in PDF
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid                    = p_spool
            no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
          IMPORTING
            pdf_bytecount                  = numbytes
            pdf_spoolid                    = pdfspoolid
            otf_pagecount                  = pagecount
           btc_jobname                    = jobname
           btc_jobcount                   = jobcount
          TABLES
            pdf                            = pdf
          EXCEPTIONS
            err_no_otf_spooljob            = 1
            err_no_spooljob                = 2
            err_no_permission              = 3
            err_conv_not_possible          = 4
            err_bad_dstdevice              = 5
            user_cancelled                 = 6
            err_spoolerror                 = 7
            err_temseerror                 = 8
            err_btcjob_open_failed         = 9
            err_btcjob_submit_failed       = 10
            err_btcjob_close_failed        = 11.
      p_subrc = sy-subrc.
    ENDFORM.                    " CONVERSIONE_SPOOL_PDF
    *&      Form  invio_mail
          text
    -->  p1        text
    <--  p2        text
    FORM invio_mail .
    Transfer the 132-long strings to 255-long strings
      LOOP AT pdf.
        TRANSLATE pdf USING ' ~'.
        CONCATENATE gd_buffer pdf INTO gd_buffer.
      ENDLOOP.
      TRANSLATE gd_buffer USING '~ '.
      DO.
        it_mess_att = gd_buffer.
        APPEND it_mess_att.
        SHIFT gd_buffer LEFT BY 255 PLACES.
        IF gd_buffer IS INITIAL.
          EXIT.
        ENDIF.
      ENDDO.
    Testo della mail
      CLEAR it_email. REFRESH it_email.
      it_email-line = 'Testo della mail'.
      APPEND it_email.
    Creazione messaggio
      email_data-obj_name      = 'MESSAGE'.
      email_data-obj_descr     = 'Conversione spool n.'.
      email_data-obj_descr+26  = p_spool.
      email_data-obj_langu     = 'I'.
      email_data-sensitivty    = 'F'.
      READ TABLE it_mess_att INDEX w_cnt.
      email_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_mess_att ).
      start_line = 1.
      DESCRIBE TABLE it_email LINES tot_line.
      packing_list-transf_bin = ' '.
      packing_list-doc_type   = 'RAW'.
      packing_list-head_start = 1.
      packing_list-head_num   = 0.
      packing_list-body_start = 1.
      packing_list-body_num   = tot_line.
      packing_list-obj_langu  = sy-langu.
      APPEND packing_list.
      APPEND LINES OF it_mess_att TO it_email.
      CLEAR packing_list.
    Riga iniziale = ultima riga messaggio precedente + 1
      start_line = tot_line + 1.
      DESCRIBE TABLE it_mess_att LINES tot_line.
      packing_list-transf_bin = 'X'.
      packing_list-head_start = 1.
      packing_list-head_num   = 1.
      packing_list-body_start = 1.
      DESCRIBE TABLE it_mess_att LINES packing_list-body_num.
      packing_list-doc_type   = 'PDF'.
      packing_list-obj_descr  = 'Allegato PDF.'.
      packing_list-doc_size   =  packing_list-body_num * 255.
      packing_list-obj_langu  = sy-langu.
      APPEND packing_list.
    destinatario interno a SAP
      receivers-receiver = sy-uname.
      receivers-rec_type = 'B'.
      receivers-express = 'X'.
      APPEND receivers.
    destinatario esterno a SAP: deve essere un idirizzo email:
    receivers-receiver = '[email protected]'.
    receivers-rec_type = 'U'.
    APPEND receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
      EXPORTING
        document_data                    = email_data
        put_in_outbox                    = 'X'
       SENDER_ADDRESS                   = SY-UNAME
        sender_address_type              = 'B'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      SENDER_ID                        =
      TABLES
        packing_list                   = packing_list
        contents_bin                   = it_mess_att
        contents_txt                   = it_email
        receivers                      = 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.
      IF sy-subrc <> 0.
    errore invio mail
      ENDIF.

    Hi,
    Try to use fm 'SO_NEW_DOCUMENT_ATT_SEND_API1' instead of SO_DOCUMENT_SEND_API1.
    Please check documentation of fm SO_DOCUMENT_SEND_API1 in ECC 6.

  • Sending an excel sheet of  to mail Ids using file to mail scenario

    Hello,
    I have a folder with three folders archive exception and log. Log folders have the details of exception. I want the XML files that are in Exception, to be sent to resp email ids with the data in it to be stored in an excel sheet( data will be collected from the log file for the correspondng file in exception).
    eg: if test.xml is in exception its log will have an exception detail somethng like " Enter a value".
    In this case i want to give the exception details as well as some relevant details with it like material number etc , time at which the exception occured . These details are to be given in an excel sheet .
    Is it possible to do using file to mail scenario. Please help by explianing the procedure.
    Regards.

    This can be done with the help of some Java and ABAP coding. I can give you a general view on how to do this.
    1. Configure a file adapter for sender to pick up the exception files.
    2. While doing the mapping, create a UDF to store the values (which you need to send it to excel file) in a table in ABAP Stack.
    3. Create a ABAP Program in R3 (which can be schedule on regular intervals depending on ur req) to create an excel sheet based on the the data in the table (created in previous step). I am not sure how easy to code ABAP program to create an excel sheet.
    4. Create one more file adapter to send this excel sheet to the corresponding mail ids.
    This is a very high level view on doing this.

  • Want to send PDF as attachement using Java Mail

    HI,
    I am using Java mail API for sending PDF as attachment. Here is my sample code
    messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler("String data for PDF using iText", "text/plain" ));
    I am generating String for PDF file using iTEXT but I am unable to find out mimetype for passing into DataHandler as second paramete.
    Any idea?
    Thanks
    Shailesh

    Don't convert the data to String. It isn't text so
    you'll damage the binary content by doing that. In
    the "demos" directory of your JavaMail download
    you'll find a ByteArrayDataSource class you can use
    instead of a FileDataSource. Yes, this worked for me. I create the pdf in memory as as StringBuffer and I just changed the code from
    messageBodyPart.setDataHandler(new DataHandler(pdf.toString(), "application/pdf"));
    to
    messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(pdf.toString(), "application/pdf")));
    and it worked.
    Thanks a lot for your help,
    Dennis

  • How to send a mail more than 255 characters in PDF format

    Hi Experts
    I am facing a problem sending an ALV list spool as an email attachment in PDF format. Here my problem is spool has morethan 255 characters, so the contents are trukated after 255.
    I am using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to send the email. Please give any good suggestion.
    Thanks in advance
    Praveen

    Hi,
    <li>After converting spool to PDF using CONVERT_ABAPSPOOLJOB_2_PDF, need to use below function module
    <li>Use SX_TABLE_LINE_WIDTH_CHANGE to convert line width to 255 chars.
       CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
          EXPORTING
            line_width_src              = 134
            line_width_dst              = 255
          TABLES
            content_in                  = i_pdf
            content_out                 = l_attachment
          EXCEPTIONS
            err_line_width_src_too_long = 1
            err_line_width_dst_too_long = 2
            err_conv_failed             = 3
            OTHERS                      = 4.
        IF sy-subrc NE 0.
          MESSAGE s000(0k) WITH 'Conversion Failed'.
          EXIT.
        ENDIF.
    Thanks
    Venkat.O

  • Problem in sending PDF as attachment in E-Mail

    Hi All,
    I have developed a program to convert the spool request as PDF file and sending it to an E-Mail address.
    But when i'm opening the file,  I'm getting an error in Adobe Reader.
    I'm attaching the code here.
    Please give me the suggestions along with example Program.
    Sorry, I could not attach the program here.
    Thanks and regards,
    Jagan Mohan.

    DATA:ig_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
         ig_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : ig_pdf1 TYPE TABLE OF solisti1.
    DATA: g_tab_lines LIKE sy-tabix.
    DATA: ig_objpack LIKE sopcklsti1 OCCURS 2  WITH HEADER LINE,
          ig_objhead LIKE solisti1   OCCURS 1  WITH HEADER LINE,
          ig_objbin LIKE solisti1   OCCURS 10 WITH HEADER LINE,
          ig_reclist LIKE somlreci1  OCCURS 5  WITH HEADER LINE,
          ig_objtxt LIKE solisti1   OCCURS 10 WITH HEADER LINE.
    DATA: wg_doc_chng LIKE sodocchgi1.
    PERFORM convert_pdf.
    PERFORM sendmail.
    FORM convert_pdf .
      REFRESH : ig_otf , ig_pdf_tab.
      ig_otf[] = wg_otf_from_fm-otfdata[].
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
          max_linewidth         = 132
        IMPORTING
          bin_filesize          = wg_bin_fsize
        TABLES
          otf                   = ig_otf
          lines                 = ig_pdf_tab
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          OTHERS                = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
        WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " convert_pdf
    FORM sendmail .
      REFRESH : ig_pdf1.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_dst              = '255'
        TABLES
          content_in                  = ig_pdf_tab[]
          content_out                 = ig_pdf1[]
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      MOVE : 'U'   TO ig_reclist-rec_type,
             '.....'   TO ig_reclist-receiver, " move email id here
             'X'    TO ig_reclist-express,
             'INT' TO ig_reclist-com_type.
      APPEND ig_reclist.
      REFRESH ig_objtxt.
      CONCATENATE 'Payslip of employee -' wg_vbak-vbeln INTO ig_objtxt SEPARATED BY ' '.
      APPEND ig_objtxt.
    Creating the document to be sent
      wg_doc_chng-obj_descr = 'Pay Slip'.
      wg_doc_chng-obj_name  = 'PAYSLIP'.
      wg_doc_chng-obj_langu = sy-langu.
    Get length of objtxt.
      DESCRIBE TABLE ig_objtxt LINES g_tab_lines.
      READ TABLE ig_objtxt INDEX g_tab_lines.
      wg_doc_chng-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( ig_objtxt ).
    Creating the entry for the compressed document
      CLEAR ig_objpack-transf_bin.
      ig_objpack-head_start = 1.
      ig_objpack-head_num   = 0.
      ig_objpack-body_start = 1.
      ig_objpack-body_num   = g_tab_lines.
      ig_objpack-doc_type   = 'RAW'.
      APPEND ig_objpack.
      DESCRIBE TABLE ig_pdf1 LINES g_tab_lines.
      g_tab_lines = g_tab_lines + 1.
      ig_objhead-line = 'PAYSLIP'.
      APPEND ig_objhead.
    Creating the entry for the compressed attachment
      ig_objpack-transf_bin = 'X'.
      ig_objpack-head_start = 1.
      ig_objpack-head_num   = 1.
      ig_objpack-body_start = 1.
      ig_objpack-body_num   = g_tab_lines.
      ig_objpack-doc_type   = 'PDF'.
      ig_objpack-obj_name   = 'PAYSLIP'.
      ig_objpack-obj_descr  = 'Pay Slip'.
      ig_objpack-doc_size   = g_tab_lines * 255.
      APPEND ig_objpack.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data                    = wg_doc_chng
         put_in_outbox                    = 'X'
          commit_work                      = 'X'
        TABLES
          packing_list                     = ig_objpack
          object_header                    = ig_objhead
          contents_bin                     = ig_pdf1
          contents_txt                     = ig_objtxt
          receivers                        = ig_reclist
       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 .
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.

  • How to capture the screen and send it to attachment for that mail

    hi sir ,
         how to capture the screen shot and attach with that e-mail , whether it is possible or not ..
    Regards,
    kumar

    hi sir,
        i am asking about while creating the support message from help menu in sap..
    while creating the support message we have to give component , priority and text also .. after that click the send icon in that support desk message .. while clicking the send button the entire screen ( what  we have entered in that creen na ) i have to capture the screen ( it may be save in local file also )  after that it will attach into attachment and then send it to ...
    Regards,
    kumar

  • Convert Binary Data into Pdf & send it as attachment in a mail from R/3

    Hi,
    Scenario:
    The interactive form saved in WebDynpro Application is sent to R/3 in binary format. It has to be converted into pdf and sent it as an attachment in mail to the respective person in workflow.
    Kindly help on these issues :
    1. How to receive the binary data in R/3 sent by the WebDynpro Application ?
    To my knowledge we can receive the binary in XSTRING data type. Plz correct me if am wrong.
    2. How do i convert the received binary data into pdf ?
    Thanks,
    Bharath Kaushik Krishnan

    HI Bharath,
    I think You can reuse teh XString for binary data.there are certain function modules in R/3 for creating pdf/for sending it as pdf attatchment.please search in abap forums you will find more information
    With Regards
    Naidu

Maybe you are looking for