cancel
Showing results for 
Search instead for 
Did you mean: 

Help in sending .XLSX extension file as attachment.

Former Member
0 Kudos

Hi All,

Could you please let me know the function module or Class which is used to send a mail with attachment .XLSX file?

I have implemented the code for .XLS using FM "SO_NEW_DOCUMENT_ATT_SEND_API1" and its working correctly.

I need help in .XLSX format attachment.

Please suggest.

Thanks in advance!!

Regards,

Shaik

Accepted Solutions (0)

Answers (2)

Answers (2)

sumeet_gehlot
Contributor
0 Kudos

Hi Shaik,

Check the standard report , let me know if still u r not able to send attachment

BCS_EXAMPLE_7

Regards,

Sumeet

Former Member
0 Kudos

Hi Shaik

Are you getting any error for .XLSX format attachment. when used with "SO_NEW_DOCUMENT_ATT_SEND_API1?

Thanks

  Arathy Nair

Former Member
0 Kudos

Hi Arathy,

We are able to upload the .XLSX file but data is not showing in mail attachment.

Any suggestion for displaying data for attached .xlsx file?

Thanks & Regards,

Shaik


dharmakasi
Active Contributor
0 Kudos

Hi Shaik,

First convert the xslx file into xstring and then do the below steps

1.

TRY.
       
CALL METHOD cl_bcs_convert=>xstring_to_solix

         
EXPORTING

            iv_xstring
= gv_data "xstring format of attachment file

          RECEIVING

            et_solix  
= ob_mail_contents.

     
CATCH cx_bcs.

       
MESSAGE e445(so).

   
ENDTRY.

2. Send email with attachment

.TRY
      lo_send_request
= cl_bcs=>create_persistent( ).
     
CHECK lo_send_request IS BOUND.

    
      lo_document
= cl_document_bcs=>create_document(

                            i_type   
= 'HTM'

                            i_text   
= ot_body

*                                i_length  = '12'

                            i_subject
= lv_subject ).



     
CHECK lo_document IS BOUND.

*     add attachment to document

     
IF ob_mail_contents IS NOT INITIAL.

       
CLEAR lv_subject.

    

         
CALL METHOD lo_document->add_attachment

           
EXPORTING

              i_attachment_type   
= 'XML'

              i_attachment_subject
= lv_subject

              i_attachment_size   
= oi_size

              i_att_content_hex   
= ob_mail_contents.

       
ENDIF.

     
ENDIF.

* add document to send request

     
CALL METHOD lo_send_request->set_document( lo_document ).

* set the sender eMail address for the "From:" field

      lv_sender_email
= text-001.

      lo_sender_id
= cl_cam_address_bcs=>create_internet_address( i_address_string = lv_sender_email ).

      lo_send_request
->set_sender( lo_sender_id ).



* Target eMail addresses

     
LOOP AT ot_recipients INTO ls_default_recipients.

        lv_recipient
= ls_default_recipients.

* create recipient

        lo_recipient
= cl_cam_address_bcs=>create_internet_address( lv_recipient ).



* add recipient with its respective attributes to send request

       
CALL METHOD lo_send_request->add_recipient

         
EXPORTING

            i_recipient
= lo_recipient

            i_express  
= 'X'.

     
ENDLOOP.



* ---------- send document ---------------------------------------

     
CALL METHOD lo_send_request->send(

       
EXPORTING

          i_with_error_screen
= 'X'

        RECEIVING

          result             
= lv_sent_to_all ).



     
IF lv_sent_to_all = 'X'.

       
WRITE:/10 'Document sent'.

     
ELSE.

       
WRITE:/10 'Document not sent to Receiver'.

     
ENDIF.
    
COMMIT WORK.

* -----------------------------------------------------------

* *                     exception handling

* -----------------------------------------------------------

   
CATCH cx_bcs INTO lo_bcs_exception.

     
WRITE:/ 'Error occured while sending email'.

     
WRITE:/ 'Type of Error:', lo_bcs_exception->error_type.

     
EXIT.

 
ENDTRY.