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.
Showing results for 
Search instead for 
Did you mean: 

How to attach a file in Email body?

Active Participant
0 Kudos


I have the email format which is been called through screen, in that I have added a new button for attaching the file(any file format).

Please check the below screenshot:

So here, when I click on the attachment, I need to get the popup for asking the document to attach,

we can do this through -> CALL METHOD cl_gui_frontend_services=>file_open_dialog

But how to attach new file to the mail body?

Please let me know about this.




Former Member
0 Kudos

Hi Hunt,

What kind of file do you want to add on email body?

Images ?

Secondly , why do u want to add file on email body, why dont u try it like attachment?

please let me know about this details.



0 Kudos

Hi Bektas,

Actually, I dont want to add file in email body, but adding a file should be like an attachment and file format is not in particular. So I need add any file as an attachment.



0 Kudos

Hello Hunt,

Are you using class cl_send_request_bcs to send an email with an attachment or Function Modules like "SO_DOCUMENT_API" is used in the program?

Would you like to display it in the screen once the documents are attached?. If yes, you would need to add a button as "Attachment List" and display the documents attached as list?

whats your requirement?

0 Kudos

Hi Sudar,

The Goal of my idea is to Attach a file(Any file) to the email.

If you see the Screenshot, Email body with sender mail id is ready(Almost everything is ready), but only thing left out is adding a new attachment to the email when the user click on the "Attachment" button

Nope, I haven`t used the SO_DOCUMENT_API. or the class: cl_send_request_bcs



0 Kudos

Nope, I haven`t used the SO_DOCUMENT_API. or the class: cl_send_request_bcs

So what are you using to send the email?

Apart this, you have to:

1- read the file as BIN or ASC (based the file extension) with cl_gui_frontend_services

2-save into your internal tables (1 for each attachment)

3-convert the BIN ones in XString

4-pass the tables to the corresponding method to generate attachment.

i suggest you to use CL_BCS class (and all its friends) since is more flexible in my opinion.

0 Kudos

Hi Simone,

I will give it a try for your update.

Active Contributor
0 Kudos

As a side note - it seems like a rather strange idea to use SAP as a mail client... Wouldn't it be easier just to call Outlook? I imagine all those attachments also would be consuming space somewhere on the SAP server. Are you sure it's a good design decision?

0 Kudos

Hi Jelena,

Its not my decision and I like your suggestion too.

I will discuss with my team about this