In Adobe froms - Sending PDF file as Attachment  via email

I have to develop a <b>PDF form</b> and one more requirement; I have to change the mail Content (body) and the Subject line which should have attached PDF file.The (Transaction Code VA21) Has the sending the Email part. My  Requirement is to <b>Change the Content (body) and the Subject</b>. 
Requirement;
When customer request for the quote, quote document is created in SAP (Transaction Code VA21). Promised Price, quantity, date is communicated to customer via quote output. Customer may decide to place firm order with reference to quote.
So this form (PDF file and send via email) is used to communicate the AMAT quote to customer. The PDF file will be as a attachment in the mail. With change subject line, and content of the mail (Thanks for the Quote, Please don’t reply to this mail). It also consists of applicable terms & condition of the quote.
Is it possible to handle the Content and the Subject of the mail in Program or Form layout (SFP). or it's Enhancement?
How to go about it? I tried a lot. At last am contacting you. Please.............. Let me know. Very urgent.Point will be given sooon. Tnx a lot.....
#Sinivas

Hi,
Yes But you can use ADOBE FORMS for that... Check this link for presentation...
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0c139d3-3eae-2910-01a1-d253f2587b0e?prtmode=navigate
Check this BLOG for sending Email through ABAP..
Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface
One more thing... You can download your data to a PDF file and send that PDF file via program...
Search this Forum for more answers.. you would get plenty out of it...
Check this thread for further information..
Sending mail with 2 attachments
Hope this would help you.
Any queries plz revert back
Good luck
Narin

Similar Messages

  • How to send txt file  as attachement in email

    Hi Experts ,
    How to send  txt file  as attachement in email .
    which function module i use

    Hi,
    Try to use this one
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    Hope it can solve your problem!
    Good luck!
    Tao

  • .pdf file changed into .tmp when trying to send pdf file as attachment

    Dears,
    A few days now, .pdf files are exported as .tmp files if we try to send them as attachment directly from the adobe reader plug-in in internet explorer 8.
    Unfortunatly Outlook interprets .tmp files as harmfull, so we are no longer able to send pdf files directly.
    (screenshot in attachment)
    Is there any chance we can configure this so, pdf files are exported as .pdf instead of .tmp
    More details:
    OS               : Win XP SP3
    browser        : ie 8
    plug in          : Adobe PDF Link Helper (not sure this is the one that provides us the pdf reader functionallity dough)

    I cannot reproduce that (Adobe Reader 11.0.3, IE8, Win XP-SP3).  In fact, I cannot even see the Attach to Email option, but the file name is correct.

  • How to Sender PDF file as attachment in Payload?

    Hi Experts,
         After I done some of PI scenarios, I'm stuck with one of my requirement... In requirement, "Web service" will send request to "SAP ECC 6" in order to get PO document print out in PDF file by call smartform or any form printing as usual.
         In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in  RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
         I try to search and read some of document and blog, some said I can attach file as Payload attachment, but no clear solution or guide to do so.
        Here is example blog that I found, I really useful
           /people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
        Please suggest me in my case,
    Thanks in advance...
    Cheers,
    Terry

    Hi,
    >>In my understand, I'm using SOAP adapter as sender and RFC adapter in receiver side, in RFC function, I will call form and generate PDF file by using normal ABAP function, but here, how can I send PDF file as response message of SYNC call from web service.
    as per my blog you can attach PDF to a message only if you use abap proxy on ECC and not RFC
    the code is just copy and paste from my blog:
    /people/michal.krawczyk2/blog/2006/04/19/xi-rfc-or-abap-proxy-abap-proxies-with-attachments
    so there is nothing spectacular there
    Regards,
    Michal Krawczyk

  • Not able to send pdf file as attachment in my apple mail.

    Hi, I was easily able to attach pdf files to my apple mail.  infact I could just open a pdf file and then send it as attachment in the email earlier. but after downloading and upgrading to os X Mountain lion, I am neither being able to attach and send pdf files in my apple mail, nor can I send PDF file as an attachment.
    Is there any issue with OS X Mountain Lion.
    Issue 1.  I compose Email , then click attach > Browse > select pdf file > click attach > it shows in my Email body either as an icon or as first page of the pdf document > I send it. >>> But when the receipient opens the Email, that pdf attachment is missing. In fact When I put a cc to my self and I open the Email, the attachment is mssing in the incoming E amil.
    Issue 2. I open the PDF document > Click on File > send as attachment in E-Mail > on right, a menu appears where I select the File and click attach> I get a message
    The SendMail doesnot know how to talk to your default mail client. Please select a different mail application to use. Attaching a screen shot.
    I never had these issues earlier with my Lion OS . but since the time I have upgraded to mountain Lion OS, I am having these issues.
    Are these the Mountain Lion issues, how to fix these please.

    I believe, the software team forgot to put a button for send or share as an attachment to preview.

  • Adobe Reader X v10.1.4 no longer sends pdf file to attached printer

    wants to save prn file.  (Adobe print command shows correct, default printer name.)  Printer works fine with other applications and used to print pdf files from Reader X even 2 weeks ago.  Windows 7 x64 with  MS Security Essentials - all systems up to date, no system changes (hard or soft) other than regular security and version updates.
    Ran Adobe Repair and rebooted - print command showing attached printer still asks where to save the prn file instead of sending job to turned on printer which works fine just before and just after Adobe fails to use it.  Will install older version of Reader, Adobe offers v9.5 if no one has a better solution since I am clueless.

    Thank you so much for trying to help.
    From your question I gather you have Reader X v 10.1.4 and have no trouble printing if you send to your printer.
    Alas I'm pointing to my one real printer, the Brother I'm sending the pdf file to print.  Worked fine for years until a few days ago.  Now when I hit "Print" on the bottom right of the below panel I get the "Save As" screen asking where I wish to save the pdf file name I'm trying to print followed by .prn.
    I have no problems in any other application printing.  If installing an earlier version of Adobe Reader proves it's not v 10.1.4 specifically, I'll have to try and send the prn file to the printer, perhaps by using the old DOS type command, or see if I can print pdf files on another system.
    You just made me think to try my backup PC with Adobe Reader X v10.1.0 - This works fine, both on its own printer and on the below named Brother attached to this system.  So the problem is either v10.1.4 or some interaction of Adobe with very recently installed Microsoft security or other OS updates for 64bit Windows 7.
    THANK YOU!

  • Sending PDF file as Attachment

    Hello Guys,
    My requirement is to send an PDF attachment which could have content in any of four languages( English,spanish,German or french).
    I am planning to use Function Module SO_NEW_DOCUMENT_SEND_API1 to send Email.
    Please let me know if it is possible to achieve this without using smartforms.
    If yes, how ?
    if no, how to achieve this using smartform.
    Appreciate your help in advance.
    Regards,
    Hema

    Hi,
    Yes But you can use ADOBE FORMS for that... Check this link for presentation...
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0c139d3-3eae-2910-01a1-d253f2587b0e?prtmode=navigate
    Check this BLOG for sending Email through ABAP..
    Sending E-Mail from ABAP - Version 610 and Higher - BCS Interface
    One more thing... You can download your data to a PDF file and send that PDF file via program...
    Search this Forum for more answers.. you would get plenty out of it...
    Check this thread for further information..
    Sending mail with 2 attachments
    Hope this would help you.
    Any queries plz revert back
    Good luck
    Narin

  • How to send zip file as attachment through email

    Hi All,
    I am having a requirement that I need to download the internal table data into .txt file and I need to zip the text file. And this zip files needs to send to the customer through email.
    I am able download the data into .txt and able to zip the file. But I am not able send the .zip file through email.
    I know that we can send .xls, .txt, .csv and also .ppt, .doc file types we can send as an attachement through abap program. But I don't know about .zip files. Is there any possibilty to send .zip file as an attachment thorugh email.
    Can any one help me how to send a .zip file thorugh email as an attachment. 
    Regards,
    vinod

    hi Vinod,
    Can you please tell me how you have zipped the file.
    I am having a text file in application server. I need to zip that file. Then the middleware moves it to Legacy system.
    I used the following code. With this I am having the data in Binary format which my midleware cannot understand.
    What I need on the whole is just to reduce the size of the file.
    form ZIP_FILE .
    DATA: lt_data TYPE TABLE OF x255,
          lt_textdata TYPE TABLE OF x255.
    DATA: ls_data LIKE LINE OF lt_data.
    DATA: lv_dsn1(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEX.TXT'.
    DATA: lv_dsn3(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEXZIP.zip'.
    *DATA: lv_dsn3(100) VALUE '/interfaces/SM5/test.zip'. " Contains sample1.xls and sample2.xls
    DATA: lv_file_length TYPE i.
    DATA: lv_content TYPE xstring.
    DATA: lo_zip TYPE REF TO cl_abap_zip.
    CREATE OBJECT lo_zip.
    Read the data as a string
    clear lv_content .
    OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
    READ DATASET lv_dsn1 INTO lv_content .
    CLOSE DATASET lv_dsn1.
    lo_zip->add( name = 'sample.TXT' content = lv_content ).
    lv_content = lo_zip->save( ).
    *clear lv_content .
    Conver the xstring content to binary
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = lv_content
    IMPORTING
    output_length = lv_file_length
    TABLES
    binary_tab = lt_data.
    OPEN DATASET lv_dsn3 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_textdata INTO ls_data.
    TRANSFER ls_data TO lv_dsn3.
    ENDLOOP.
    CLOSE DATASET lv_dsn3.
    IF sy-subrc EQ '0'.
        MESSAGE s999(zfi_ap_gl) WITH text-t10.
      ENDIF.
    Can you please help.
    Thanks Aravind

  • Sending pdf as an attachment in email with all changes done on the pdf

    Hello Everyone,
    I have developed a webdynpro java application which sends a interactive form as an attachment in an email. Everything works fine except that there are some editable fields on the form and the changes dont go in the attachment. The Send Email button is on the webdynpro View. I tried many different things but nothing worked. Somehow the changes done on the form dont get saved in the pdfSource when a button on the webdynpro view is clicked. Any help would be very much appreciated.
    Thanks,
    Saika.

    Hi Hari,
    check this link: http://help.sap.com/saphelp_nw70/helpdata/en/51/d5cd16235e4643ae8ec92395c4ad97/frameset.htm
    Also search on SDN, you will get many thread links with same question
    ABAP Proxy Attachment
    Regards,
    Praveen Gujjeti

  • I can't use thunderbird 31.2.0 to send attachement from a pdf file with Acrobat PRO XI

    I can't use thunderbird 31.2.0 (Mozilla) to send attachement from a pdf file with Acrobat PRO XI. Each time, Acrobat replies (in french) : "il n'y a pas de client pour la messagerie par défaut". Thunderbird is indicated as "by default" in the list of programs of Windows.
    Even if I type my e-mail address, etc. in the account of Acrobat, it doesn't change. Each time, I have to record a PDF file in a folder and return to Thunderbird to send it as attached. It is a too long process,  compared with Windows XP with Acrobat Reader or Acrobat 5, I had before.
    Would you please help me to explain the process. My OS is Windows 8.1.
    Thank you

    Thank you for your answer.
    What i want to do : to send PDF files as attached documents in a message
    generated by thunderbird by my e-mail address [email protected] or
    another one I have.
    When I introduce my e-mail address under Edit-Preferences-Email
    Accounts, Acrobat ask the e-mail account, the password, the IMAP for
    ingoing message (and I use POP) and SMTP for outgoing messages. Even I
    introduce all the datas, it doesn't change, Acrobat is unable to send
    the message. And the process is not convenient, because I need all my
    outgoing messages be documented inside Thunderbird.
    So, I repeat my request : how can I use thenderbird as program by
    default from Acrobat or any other software ?
    Thank you for your next message.
    Jean-Luc Rongé
    Le 21-10-14 14:24, ANAND8502 a écrit :
    >
          I can't use thunderbird 31.2.0 to send attachement from a pdf
          file with Acrobat PRO XI
    created by ANAND8502 <https://forums.adobe.com/people/ANAND8502> in
    /Acrobat Installation & Update Issues/ - View the full discussion
    <https://forums.adobe.com/message/6850947#6850947>

  • Error opening PDF file when send as attachment via email

    Hi,
    I searched around the forum to resolve my issue and there's alot of post that is related but i can't find any answer to my issues.
    Here's the scenario :-
    I try to convert the smartform to PDF and then send the PDF as an attachment via email.
    After converting the smartform to PDF, i managed to download the file and view it without any problem but i can't view the PDF as an attachment. It has the following error :-
    Adobe Reader could not open '4500002325.PDF' because it is either not a supported fle type or because the file has been damaged (for example, it was sent as an email and wasn't correctly decoded
    The following is the snapshot of my code:-
    * Determine smartform function module for invoice
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = lf_formname
        IMPORTING
          fm_name            = lf_fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
    *  error handling
        ent_retco = sy-subrc.
        PERFORM protocol_update_i.
      ENDIF.
      ls_control_param-getotf = 'X'.
      CALL FUNCTION lf_fm_name
        EXPORTING
          archive_index        = toa_dara
          archive_parameters   = arc_params
          control_parameters   = ls_control_param
          mail_recipient       = ls_recipient
          mail_sender          = ls_sender
          output_options       = ls_composer_param
          zxekko               = l_doc-xekko  " user_settings = ' '
          zxpekko              = l_doc-xpekko
        IMPORTING
          document_output_info = l_ssfcrespd
          job_output_info      = l_ssfcrescl
          job_output_options   = l_ssfcresop
        TABLES
          l_xekpo              = l_doc-xekpo[]
          l_xekpa              = l_doc-xekpa[]
          l_xpekpo             = l_doc-xpekpo[]
          l_xeket               = l_doc-xeket[]
          l_xtkomv             = l_doc-xtkomv[]
          l_xekkn              = l_doc-xekkn[]
          l_xekek              = l_doc-xekek[]
          l_xkomk              = l_xkomk
        EXCEPTIONS
          formatting_error     = 1
          internal_error       = 2
          send_error           = 3
          user_canceled        = 4
          OTHERS               = 5.
      IF sy-subrc = 0.
        CALL FUNCTION 'CONVERT_OTF'
          EXPORTING
            FORMAT                = 'PDF'
          IMPORTING
            BIN_FILESIZE          = v_len_in
            BIN_FILE              = v_bin_file
          TABLES
            OTF                   = l_ssfcrescl-otfdata
            LINES                 = l_pdf
          EXCEPTIONS
            ERR_MAX_LINEWIDTH     = 1
            ERR_FORMAT            = 2
            ERR_CONV_NOT_POSSIBLE = 3
            ERR_BAD_OTF           = 4
            OTHERS                = 5.
    * email subject
        CONCATENATE 'Purchase order' l_doc-xekko-ebeln INTO lw_subject
                    SEPARATED BY space.
    * RECIPIENTS
        lwa_recipients-rec_type = 'U'.
        lwa_recipients-express = 'X'.
        SELECT adr6~smtp_addr
        INTO TABLE gv_smtp_addr
        FROM ekko AS ekko INNER JOIN
             lfa1 AS lfa1 ON ekko~lifnr      = lfa1~lifnr INNER JOIN
             adr6 AS adr6 ON adr6~addrnumber = lfa1~adrnr
        WHERE ekko~ebeln = l_doc-xekko-ebeln.
        IF NOT gv_smtp_addr[] IS INITIAL.
          LOOP AT gv_smtp_addr INTO gv_smtp_addr_line FROM 2.
            lwa_recipients-receiver = gv_smtp_addr_line.
            lwa_recipients-copy = ''.
            APPEND lwa_recipients TO ptb_recipients.
          ENDLOOP.
    * Text Data
            CALL FUNCTION 'READ_TEXT'
              EXPORTING
                id                      = 'ST'
                language                = 'E'
                name                    = 'TEST'
                object                  = 'TEXT'
              TABLES
                lines                   = lv_lines
              EXCEPTIONS
                id                      = 1
                language                = 2
                name                    = 3
                not_found               = 4
                object                  = 5
                reference_check         = 6
                wrong_access_to_archive = 7
                OTHERS                  = 8.
          LOOP AT lv_lines INTO lv_lines_line.
            ltb_objtxt = lv_lines_line-tdline.
            APPEND ltb_objtxt.
          ENDLOOP.
          DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.
          READ TABLE ltb_objtxt INDEX lw_tab_lines.
    * document data contains information for the whole message
          lwa_doc_chng-obj_descr = 'ABAPlist'.
    * Control Data
          lwa_doc_chng-obj_name   = 'TESTING'.
          lwa_doc_chng-sensitivty = 'F'.
          lwa_doc_chng-no_change  = 'X'.
          lwa_doc_chng-priority   = '1'.
          lwa_doc_chng-obj_prio   = '1'.
          lwa_doc_chng-obj_langu  = sy-langu.
          CLEAR ltb_objpack-transf_bin.
    *Attachment
    *Move the binary attachment to other internal table.
          ltb_objpack-head_start = 1.
          ltb_objpack-head_num   = 0.
          ltb_objpack-body_start = 1.
          ltb_objpack-body_num   = lw_tab_lines.
          ltb_objpack-doc_type   = 'RAW'.
          APPEND ltb_objpack.
          clear : lw_tab_lines.
    *Get the number of lines in the Attachment (PDF FILE)
    *      DESCRIBE TABLE it_mess_att LINES lw_tab_lines.
          DESCRIBE TABLE l_objbin lines lw_tab_lines.
          ltb_objpack-transf_bin = 'X'.
          ltb_objpack-head_start = 1.
          ltb_objpack-head_num   = 1.
          ltb_objpack-body_start = 1.
          ltb_objpack-body_num = lw_tab_lines.
          ltb_objpack-doc_type = 'PDF'.
          ltb_objpack-obj_descr = l_doc-xekko-ebeln.
          ltb_objpack-doc_size = lw_tab_lines * 255.
          APPEND ltb_objpack.
    *Email Subject
          lwa_doc_chng-obj_descr = lw_subject.
            lwa_recipients-receiver = recipeint.
            lwa_recipients-rec_type = 'U'.
            lwa_recipients-copy     = 'X'.
            lwa_recipients-express  = 'X'.
            APPEND lwa_recipients TO ptb_recipients.
          CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
            EXPORTING
              document_data = lwa_doc_chng
              COMMIT_WORK   = 'X'
            TABLES
              packing_list  = ltb_objpack
              contents_bin  = l_objbin
              contents_txt  = ltb_objtxt
              receivers     = ptb_recipients.
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
      ENDIF.
    Edited by: ~loObie on Apr 23, 2010 12:01 PM
    Edited by: ~loObie on Apr 23, 2010 12:02 PM

    Did you send the pdf in the following format ...
    2. Sending PDF as mail.
    CLEAR t_receivers.
    REFRESH t_receivers.
    t_receivers-receiver = sy-uname.
    t_receivers-rec_type = 'B'.
    t_receivers-com_type = 'INT'.
    t_receivers-notif_del = 'X'.
    t_receivers-notif_ndel = 'X'.
    APPEND t_receivers.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
    document_data = w_doc_data
    put_in_outbox = 'X'
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = 'X'
    IMPORTING
    sent_to_all = w_sent_all
    TABLES
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    Quote from the Following [LINK|http://www.sap-basis-abap.com/smartforms/convert-the-smart-form-into-pdf-and-send.htm]

  • Saving One or Two pages from a PDF file

    How do I save one or two pages from a PDF file that have been emailed to me? 

    Hi molalla98,
    The task that you are trying to perform is not possible via Adobe Reader, You would require Adobe Acrobat to extract the pages from Multi-Page PDF and save it accordingly.
    ~Pranav

  • Mail in Mavericks sending my filled form Adobe Acrobat Pro PDF files blank, this didn't happened in Mountain Lion, please help!!! :(

    Mail in Mavericks sending my filled form Adobe Acrobat Pro PDF files blank, this didn't happened in Mountain Lion, this where created in Adobe Acrobat Pro X and never had any problems in Monutain Lion, please help me

    Thanks for your response, it is a mail problem, I been sendings filled form PDFs estimates for years from my Mac then yesterday I went from mountain lion to mavericks and the problem started, if I zip or move te files to any other windows or Mac computer it opens fine, the problem is when I attach it to a message in mail it attached the file blank

  • Send PDF file as an attachement en an email (only 1 st page send?)

    Hi all !
    I have a requirement to send a spool job as an .PDF attachement via email for my client.
    I was using the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert a spool into a PDF file
    Then Convert PDF from 132 to 255 characters.
    Then I use the following code from the forum to send the attachment to email
    Document information.
              W_DOC_CHNG-OBJ_NAME = 'ATTACHMENT'.
              W_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
              CONCATENATE TEXT-T07 PN-PABRP PN-PABRJ INTO W_DOC_CHNG-OBJ_DESCR separated by space.
              W_DOC_CHNG-SENSITIVTY = 'F'. "Functional object
             W_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
              W_DOC_CHNG-DOC_SIZE = V_LINES_BIN * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
             CLEAR I_OBJPACK-TRANSF_BIN.
              I_OBJPACK-TRANSF_BIN = ''.
    Start line of object header in transport packet
              I_OBJPACK-HEAD_START = 1.
    Number of lines of an object header in object packet
              I_OBJPACK-HEAD_NUM = 0.
    Start line of object contents in an object packet
              I_OBJPACK-BODY_START = 1.
    Number of lines of the object contents in an object packet
              I_OBJPACK-BODY_NUM = V_LINES_TXT.
    Code for document class
              I_OBJPACK-DOC_TYPE = 'RAW'.
              I_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
              APPEND I_OBJPACK.
    Packing as PDF.
              I_OBJPACK-TRANSF_BIN = 'X'.
              I_OBJPACK-HEAD_START = 1.
              I_OBJPACK-HEAD_NUM = 1.
              I_OBJPACK-BODY_START = 1.
              I_OBJPACK-BODY_NUM = V_LINES_BIN.
              I_OBJPACK-DOC_TYPE = 'PDF'.
              I_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
              CONCATENATE 'Remuneration_Statements_' PN-PABRP '_' PN-PABRJ  '.pdf'
              INTO I_OBJPACK-OBJ_DESCR.
              I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255.
              APPEND I_OBJPACK.
              clear I_OBJPACK.
    Document information.
              CLEAR I_RECLIST.
    e-mail receivers.
              read table it_pernr into wa_pernr
                  with key pernr = pernr-pernr binary search.
              if sy-subrc eq 0.
                I_RECLIST-RECEIVER = wa_pernr-usrid.
              endif.
              I_RECLIST-COM_TYPE = 'INT'.                   "Internet Email
    *I_RECLIST-notif_del  = 'X'.
    *I_RECLIST-notif_ndel = 'X'.
              I_RECLIST-EXPRESS = 'X'.
              I_RECLIST-REC_TYPE = 'U'. "Internet address
              APPEND I_RECLIST.
              CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
                  DOCUMENT_DATA                    = W_DOC_CHNG
              PUT_IN_OUTBOX                    = ' '
                  COMMIT_WORK                      = 'X'
            IMPORTING
              SENT_TO_ALL                      =
              NEW_OBJECT_ID                    =
              TABLES
                 PACKING_LIST                     = I_OBJPACK
       OBJECT_HEADER                    = W_OBJHEAD
           CONTENTS_BIN                     = I_OBJBIN
           CONTENTS_TXT                     = I_OBJTXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
            RECEIVERS                        = I_RECLIST
    The email did succesfully send to the receipents but only the first page of the PDF attachement file was sent not the 2nd page.
    Can any body help ?
    Thanks a lot

    Hi all !
    I have a requirement to send a spool job as an .PDF attachement via email for my client.
    I was using the FM CONVERT_ABAPSPOOLJOB_2_PDF to convert a spool into a PDF file
    Then Convert PDF from 132 to 255 characters.
    Then I use the following code from the forum to send the attachment to email
    Document information.
              W_DOC_CHNG-OBJ_NAME = 'ATTACHMENT'.
              W_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
              CONCATENATE TEXT-T07 PN-PABRP PN-PABRJ INTO W_DOC_CHNG-OBJ_DESCR separated by space.
              W_DOC_CHNG-SENSITIVTY = 'F'. "Functional object
             W_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
              W_DOC_CHNG-DOC_SIZE = V_LINES_BIN * 255.
    Pack to main body as RAW.
    Obj. to be transported not in binary form
             CLEAR I_OBJPACK-TRANSF_BIN.
              I_OBJPACK-TRANSF_BIN = ''.
    Start line of object header in transport packet
              I_OBJPACK-HEAD_START = 1.
    Number of lines of an object header in object packet
              I_OBJPACK-HEAD_NUM = 0.
    Start line of object contents in an object packet
              I_OBJPACK-BODY_START = 1.
    Number of lines of the object contents in an object packet
              I_OBJPACK-BODY_NUM = V_LINES_TXT.
    Code for document class
              I_OBJPACK-DOC_TYPE = 'RAW'.
              I_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
              APPEND I_OBJPACK.
    Packing as PDF.
              I_OBJPACK-TRANSF_BIN = 'X'.
              I_OBJPACK-HEAD_START = 1.
              I_OBJPACK-HEAD_NUM = 1.
              I_OBJPACK-BODY_START = 1.
              I_OBJPACK-BODY_NUM = V_LINES_BIN.
              I_OBJPACK-DOC_TYPE = 'PDF'.
              I_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
              CONCATENATE 'Remuneration_Statements_' PN-PABRP '_' PN-PABRJ  '.pdf'
              INTO I_OBJPACK-OBJ_DESCR.
              I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255.
              APPEND I_OBJPACK.
              clear I_OBJPACK.
    Document information.
              CLEAR I_RECLIST.
    e-mail receivers.
              read table it_pernr into wa_pernr
                  with key pernr = pernr-pernr binary search.
              if sy-subrc eq 0.
                I_RECLIST-RECEIVER = wa_pernr-usrid.
              endif.
              I_RECLIST-COM_TYPE = 'INT'.                   "Internet Email
    *I_RECLIST-notif_del  = 'X'.
    *I_RECLIST-notif_ndel = 'X'.
              I_RECLIST-EXPRESS = 'X'.
              I_RECLIST-REC_TYPE = 'U'. "Internet address
              APPEND I_RECLIST.
              CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
                  DOCUMENT_DATA                    = W_DOC_CHNG
              PUT_IN_OUTBOX                    = ' '
                  COMMIT_WORK                      = 'X'
            IMPORTING
              SENT_TO_ALL                      =
              NEW_OBJECT_ID                    =
              TABLES
                 PACKING_LIST                     = I_OBJPACK
       OBJECT_HEADER                    = W_OBJHEAD
           CONTENTS_BIN                     = I_OBJBIN
           CONTENTS_TXT                     = I_OBJTXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
            RECEIVERS                        = I_RECLIST
    The email did succesfully send to the receipents but only the first page of the PDF attachement file was sent not the 2nd page.
    Can any body help ?
    Thanks a lot

  • Sending PDF file in presentation layer as a attachment to Email

    Hi,
    I have a PDF file in my Presentation layer, I want to send it as a attachment to Email. Is there any Function Module or sample code to it.
    Regards,
    Adithya M.

    Hi Maha,
    Go through this hope u can understand. also check this link
    http://abapcode.blogspot.com/2007/05/convert-spool-request-to-pdf-and-send.html.
    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_NREDDY_PDF_MAIL
    REPORT ZTEST_NREDDY_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF[] = W_RETURN-OTFDATA[].
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC <> 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN[] = I_RECORD[].
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = '[email protected]'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    IF SY-SUBRC <> 0.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8.
    *& Report ZSPOOLTOPDF *
    *& Converts spool request into PDF document and emails it to *
    *& recipicant. *
    *& Execution *
    *& This program can be run in background or online and a spool request *
    *& will still be created *
    REPORT zspooltopdf.
    PARAMETER: p_email1 LIKE somlreci1-receiver
    DEFAULT ‘[email protected]’,
    p_sender LIKE somlreci1-receiver
    DEFAULT ‘[email protected]’,
    p_delspl AS CHECKBOX,
    p_online no-display.
    *DATA DECLARATION
    DATA: gd_recsize TYPE i.
    Spool IDs
    TYPES: BEGIN OF t_tbtcp.
    INCLUDE STRUCTURE tbtcp.
    TYPES: END OF t_tbtcp.
    DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
    wa_tbtcp TYPE t_tbtcp.
    Job Runtime Parameters
    DATA: gd_eventid LIKE tbtcm-eventid,
    gd_eventparm LIKE tbtcm-eventparm,
    gd_external_program_active LIKE tbtcm-xpgactive,
    gd_jobcount LIKE tbtcm-jobcount,
    gd_jobname LIKE tbtcm-jobname,
    gd_stepcount LIKE tbtcm-stepcount,
    gd_error TYPE sy-subrc,
    gd_reciever TYPE sy-subrc.
    DATA: w_recsize TYPE i,
    w_spool_nr like sy-spono.
    %_print LIKE pri_params.
    DATA: gd_subject LIKE sodocchgi1-obj_descr,
    it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    gd_sender_type LIKE soextreci1-adr_typ,
    gd_attachment_desc TYPE so_obj_nam,
    gd_attachment_name TYPE so_obj_des.
    Spool to PDF conversions
    DATA: gd_spool_nr LIKE tsp01-rqident,
    gd_destination LIKE rlgrap-filename,
    gd_bytecount LIKE tst01-dsize,
    gd_buffer TYPE string.
    Binary store for PDF
    DATA: BEGIN OF it_pdf_output OCCURS 0.
    INCLUDE STRUCTURE tline.
    DATA: END OF it_pdf_output.
    CONSTANTS: c_dev LIKE sy-sysid VALUE ‘DEV’,
    c_no(1) TYPE c VALUE ‘ ‘,
    c_device(4) TYPE c VALUE ‘LOCL’.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Write statement to represent report output. Spool request is created
    if write statement is executed in background. This could also be an
    ALV grid which would be converted to PDF without any extra effort
    WRITE ‘Hello World’.
    new-page.
    commit work.
    new-page print off.
    If p_online = ‘X’.
    Processing performed when program calls itself when run online
    gd_spool_nr = sy-spono.
    EXPORT gd_spool_nr TO MEMORY ID ‘SPOOLTOPDF’.
    EXIT.
    endif.
    IF sy-batch EQ ‘X’.
    PERFORM get_job_details.
    PERFORM obtain_spool_id.
    ELSE.
    gd_spool_nr = sy-spono.
    If executed online, it submits a program to perform the write
    statements
    instructing it to create a spool request, this could be another
    program
    which just performs the write statements and then exports sy-spono
    to memory. But in this example it calls itself passing X to parameter
    p_online, which takes it down an alternative procesing path.
    submit ZSPOOLTOPDF
    with p_online = ‘X’
    to sap-spool
    spool parameters %_print
    archive parameters %_print
    without spool dynpro
    and return.
    ENDIF.
    Get spool id from program called above
    IMPORT gd_spool_nr FROM MEMORY ID ‘SPOOLTOPDF’.
    PERFORM convert_spool_to_pdf.
    PERFORM process_email.
    if p_delspl EQ ‘X’.
    PERFORM delete_spool.
    endif.
    IF sy-sysid = c_dev.
    wait up to 5 seconds.
    SUBMIT rsconn01 WITH mode = ‘INT’
    WITH output = ‘X’
    AND RETURN.
    ENDIF.
    FORM obtain_spool_id *
    FORM obtain_spool_id.
    CHECK NOT ( gd_jobname IS INITIAL ).
    CHECK NOT ( gd_jobcount IS INITIAL ).
    SELECT * FROM tbtcp
    INTO TABLE it_tbtcp
    WHERE jobname = gd_jobname
    AND jobcount = gd_jobcount
    AND stepcount = gd_stepcount
    AND listident ‘0000000000&#8242;
    ORDER BY jobname
    jobcount
    stepcount.
    READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
    IF sy-subrc = 0.
    message s004(zdd) with gd_spool_nr.
    gd_spool_nr = wa_tbtcp-listident.
    MESSAGE s004(zdd) WITH gd_spool_nr.
    ELSE.
    MESSAGE s005(zdd).
    ENDIF.
    ENDFORM.
    FORM get_job_details *
    FORM get_job_details.
    Get current job details
    CALL FUNCTION ‘GET_JOB_RUNTIME_INFO’
    IMPORTING
    eventid = gd_eventid
    eventparm = gd_eventparm
    external_program_active = gd_external_program_active
    jobcount = gd_jobcount
    jobname = gd_jobname
    stepcount = gd_stepcount
    EXCEPTIONS
    no_runtime_info = 1
    OTHERS = 2.
    ENDFORM.
    FORM convert_spool_to_pdf *
    FORM convert_spool_to_pdf.
    CALL FUNCTION ‘CONVERT_ABAPSPOOLJOB_2_PDF’
    EXPORTING
    src_spoolid = gd_spool_nr
    no_dialog = c_no
    dst_device = c_device
    IMPORTING
    pdf_bytecount = gd_bytecount
    TABLES
    pdf = it_pdf_output
    EXCEPTIONS
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    err_btcjob_open_failed = 9
    err_btcjob_submit_failed = 10
    err_btcjob_close_failed = 11
    OTHERS = 12.
    CHECK sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
    LOOP AT it_pdf_output.
    TRANSLATE it_pdf_output USING ‘ ~’.
    CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
    ENDLOOP.
    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.
    ENDFORM.
    FORM process_email *
    FORM process_email.
    DESCRIBE TABLE it_mess_att LINES gd_recsize.
    CHECK gd_recsize > 0.
    PERFORM send_email USING p_email1.
    perform send_email using p_email2.
    ENDFORM.
    FORM send_email *
    –> p_email *
    FORM send_email USING p_email.
    CHECK NOT ( p_email IS INITIAL ).
    REFRESH it_mess_bod.
    Default subject matter
    gd_subject = ‘Subject’.
    gd_attachment_desc = ‘Attachname’.
    CONCATENATE ‘attach_name’ ‘ ‘ INTO gd_attachment_name.
    it_mess_bod = ‘Message Body text, line 1&#8242;.
    APPEND it_mess_bod.
    it_mess_bod = ‘Message Body text, line 2…’.
    APPEND it_mess_bod.
    If no sender specified - default blank
    IF p_sender EQ space.
    gd_sender_type = space.
    ELSE.
    gd_sender_type = ‘INT’.
    ENDIF.
    Send file by email as .xls speadsheet
    PERFORM send_file_as_email_attachment
    tables it_mess_bod
    it_mess_att
    using p_email
    ‘Example .xls documnet attachment’
    ‘PDF’
    gd_attachment_name
    gd_attachment_desc
    p_sender
    gd_sender_type
    changing gd_error
    gd_reciever.
    ENDFORM.
    FORM delete_spool *
    FORM delete_spool.
    DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
    ld_spool_nr = gd_spool_nr.
    CHECK p_delspl c_no.
    CALL FUNCTION ‘RSPO_R_RDELETE_SPOOLREQ’
    EXPORTING
    spoolid = ld_spool_nr.
    ENDFORM.
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    FORM send_file_as_email_attachment tables it_message
    it_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
    DATA: ld_error TYPE sy-subrc,
    ld_reciever TYPE sy-subrc,
    ld_mtitle LIKE sodocchgi1-obj_descr,
    ld_email LIKE somlreci1-receiver,
    ld_format TYPE so_obj_tp ,
    ld_attdescription TYPE so_obj_nam ,
    ld_attfilename TYPE so_obj_des ,
    ld_sender_address LIKE soextreci1-receiver,
    ld_sender_address_type LIKE soextreci1-adr_typ,
    ld_receiver LIKE sy-subrc.
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
    t_contents like solisti1 occurs 0 with header line,
    t_receivers like somlreci1 occurs 0 with header line,
    t_attachment like solisti1 occurs 0 with header line,
    t_object_header like solisti1 occurs 0 with header line,
    w_cnt type i,
    w_sent_all(1) type c,
    w_doc_data like sodocchgi1.
    ld_email = p_email.
    ld_mtitle = p_mtitle.
    ld_format = p_format.
    ld_attdescription = p_attdescription.
    ld_attfilename = p_filename.
    ld_sender_address = p_sender_address.
    ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
    w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = ‘SAPRPT’.
    w_doc_data-obj_descr = ld_mtitle .
    w_doc_data-sensitivty = ‘F’.
    Fill the document data and get size of attachment
    CLEAR w_doc_data.
    READ TABLE it_attach INDEX w_cnt.
    w_doc_data-doc_size =
    ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
    w_doc_data-obj_langu = sy-langu.
    w_doc_data-obj_name = ‘SAPRPT’.
    w_doc_data-obj_descr = ld_mtitle.
    w_doc_data-sensitivty = ‘F’.
    CLEAR t_attachment.
    REFRESH t_attachment.
    t_attachment[] = it_attach[].
    Describe the body of the message
    CLEAR t_packing_list.
    REFRESH t_packing_list.
    t_packing_list-transf_bin = space.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 0.
    t_packing_list-body_start = 1.
    DESCRIBE TABLE it_message LINES t_packing_list-body_num.
    t_packing_list-doc_type = ‘RAW’.
    APPEND t_packing_list.
    Create attachment notification
    t_packing_list-transf_bin = ‘X’.
    t_packing_list-head_start = 1.
    t_packing_list-head_num = 1.
    t_packing_list-body_start = 1.
    DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
    t_packing_list-doc_type = ld_format.
    t_packing_list-obj_descr = ld_attdescription.
    t_packing_list-obj_name = ld_attfilename.
    t_packing_list-doc_size = t_packing_list-body_num * 255.
    APPEND t_packing_list.
    Add the recipients email address
    CLEAR t_receivers.
    REFRESH t_receivers.
    t_receivers-receiver = ld_email.
    t_receivers-rec_type = ‘U’.
    t_receivers-com_type = ‘INT’.
    t_receivers-notif_del = ‘X’.
    t_receivers-notif_ndel = ‘X’.
    APPEND t_receivers.
    CALL FUNCTION ‘SO_DOCUMENT_SEND_API1&#8242;
    EXPORTING
    document_data = w_doc_data
    put_in_outbox = ‘X’
    sender_address = ld_sender_address
    sender_address_type = ld_sender_address_type
    commit_work = ‘X’
    IMPORTING
    sent_to_all = w_sent_all
    TABLES
    packing_list = t_packing_list
    contents_bin = t_attachment
    contents_txt = it_message
    receivers = t_receivers
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    Populate zerror return code
    ld_error = sy-subrc.
    Populate zreceiver return code
    LOOP AT t_receivers.
    ld_receiver = t_receivers-retrn_code.
    ENDLOOP.
    ENDFORM.
    Reward points if helpful
    Thanks
    Naveen khan

Maybe you are looking for