Quantcast
Channel: SCN: Message List - SAP CRM: Webclient UI - Framework
Viewing all articles
Browse latest Browse all 7775

Re: Help in sending .XLSX extension file as attachment.

$
0
0

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.

 

 


Viewing all articles
Browse latest Browse all 7775

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>