Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Read email attachment from SOST and send same file to different mail IDs

former_member216877
Participant
0 Kudos
803

Hi,

Is it possible to read an attachment from SOST to my custom program and send same attachment to a different mail ID ? I

Thanks,

Devesh

5 REPLIES 5

Sandra_Rossi
Active Contributor
220

Attachment or email? I guess you mean "read an attachment of an existing email, and send a new email with this attachment".

Read the email with CL_DOCUMENT_BCS=>GETU_INSTANCE_BY_KEY, read the attachment with methods IF_DOCUMENT_BCS~GET_BODY_PART_*.

Then create a new email as usual.

Eventually you may copy the email instance to a new instance with the method IF_COPY_BCS~COPY, change its recipient and send it as usual.

220

I didn't test, but something like this - please correct the syntax errors and do some debug to adjust the code as you wish:

DATA(email) = CL_DOCUMENT_BCS=>GETU_INSTANCE_BY_KEY(
                    i_docno = '000000109060'
                    i_doctp = 'RAW'
                    i_docyr = '42' ).
DATA(part_count) = email->if_document_bcs~GET_BODY_PART_COUNT( ).
DO part_count TIMES. " main text and attachments
  DATA(part_attributes) = email->if_document_bcs~get_body_part_attributes( im_part = sy-index ).
  DATA(part_content) = email->if_document_bcs~get_body_part_content( im_part = sy-index ).
ENDDO.

Eventually:

DATA(new_email) = CAST cl_document_bcs( email->if_copy_bcs~copy( ) ).

220

Hi, This code worked for me after little changes. Thank you so much 🙂

0 Kudos
220

Nice. Eventually post the code with corrections and hints for future visitors. Thank you!

former_member216877
Participant
0 Kudos
220

Any sample code will be helpful to me ..