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 PDF (or WORD) file from application server and send as email attachmen

Former Member
0 Kudos

hi all,

We've done the following:

1. read spool data and convert it to PDF, and send as email attachment

2. read a tab delimited file on application server, as send as email body.

Now we have a requirement to read and send as email attachment a existing PDF(WORD) file under a specified directory of application server.

Please kindly advice how should we do this.

Thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello,

Since the file (PDF or WORD) is on the application server, you need to use the OPEN DATASET and READ DATASET to process the contents into an internal table.

Hit Button F1 on DATASET to get more details.

Once the data is read on the internal table, you can use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to maeil the contents as an atachment.

Hope this helps.

Regards,

Mansi.

5 REPLIES 5

Former Member
0 Kudos

Hello,

Since the file (PDF or WORD) is on the application server, you need to use the OPEN DATASET and READ DATASET to process the contents into an internal table.

Hit Button F1 on DATASET to get more details.

Once the data is read on the internal table, you can use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to maeil the contents as an atachment.

Hope this helps.

Regards,

Mansi.

0 Kudos

hi Mansi,

thanks for the advise.

we're able read the PDF file into a internal table now. However we found that the attached file is not able to open.

(error message: There was an error opening this document. The file is damaged and could not be repaired).

we've check the file on application server by downloading it with CG3Y and confirm it is not corrupt.

below is the code we use to build the internal table. please advise if anything is not correct.

(neither append the t_interna to it_mess_att, nor translate it_pdf using ' ~' is working.

refresh it_mess_att.

if not v_attach is initial.

OPEN DATASET v_attach FOR INPUT IN BINARY MODE.

if sy-subrc EQ 0.

DO.

READ DATASET v_attach INTO t_interna.

if sy-subrc EQ 0.

  • translate it_pdf using ' ~'.

  • CONCATENATE gd_buffer it_pdf INTO gd_buffer.

  • clear it_pdf.

append t_interna to it_mess_att.

clear t_interna.

else.

exit.

endif.

ENDDO.

  • 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.

close dataset v_attach.

endif.

endif.

thanks.

0 Kudos

We just found out that the code is working for Word file. Meaning we're able to send Word file from application server as attachment. And no open to open it in email.

We'll look into how to handle the PDF file.

0 Kudos

Hi,

I have also requirement to send PDF file from application server in email. Can you give details if you have found some solution.

Regards,

Gautam Joshi.

Former Member
0 Kudos

Hi Reetha,

I felt extremely relaxed when I found this thread over SDN.

Now I feel my requirement wil get fulfilled, but will require help and guidance from your end.

My requirement is to send a PDF file as an attachment in an email.

Can you provide me with the info of how to send the contents, as I must be doing some mistake.

The attachment does not have any data.

Since you have written that you have successfully sent word file as well as PDF file as attachments, so you can help me out.

I am converting a smartform in a PDF file using FM - CONVERT_OTF_2_PDF.

Now this gives the data in a internal table which has "TLINE" as its line type.

The problem is that the FM - SO_DOCUMENT_SEND_API1 sends attachment data in the "contents_bin" tables option which has line type as "LINE". So the PDF converted data internal table cannot be passed to the "contents_bin" field directly.

Please respond to my query as soon as possible cos I have been serachong for my query since a long time and I need to close this requirement immediately.

Thanks and Regards,

Pankaj Agarwal.