Error to Send PDF file using mail

Hi all,
I create a report that send an mail with 2 different pdf attach.
I have a problem because one pdf attach is 663 KB and when I read it in mail it can not open the file and give me this error  :
"Error opening PDF file --> There was an error opening this document.the file is damaged and could not be repareid "
I send the same mail with another PDF file (64,2 KB) and all it's work correct.
This files are in my application server, and this is the code that I use to read and send :
data:   gt_table TYPE TABLE OF solix,
           gs_table LIKE LINE OF gt_table.
open dataset wa for input in binary mode.
if sy-subrc eq 0.
  do.
    read dataset wa into gs_table LENGTH alen.
    ctr = ctr + alen.
    if sy-subrc ne 0.
      exit.
    endif.
    append gs_table to gt_table.
  enddo.
endif.
close dataset wa.
TRY.
(1) crea Oggetto
      l_send_request = cl_bcs=>create_persistent( ).
(2) E-Mail - Crea Oggetto e Body del messaggio
(5)  bcs attachment
l_attachment_size = ctr."tab_lines * 255.
      CALL METHOD l_doc->add_attachment
        EXPORTING
          i_attachment_type    = 'PDF'
          i_attachment_subject = l_attachment_subj
          i_attachment_size    = l_attachment_size
          i_att_content_hex    = gt_table."xsolix[].
CALL METHOD l_send_request->set_document( l_doc ).
      CALL METHOD l_send_request->set_priority
        EXPORTING
          i_priority = '1'.
      CALL METHOD l_send_request->set_send_immediately( 'X' ).
I find this link but the problem are not resolve : Compress Smartform PDF file before sending mail
Can anyone help me to understand where is the problem ?
thanks a lot
Barbara

Hi,
I find the way to resolve this topic, thanking a collegue.
The problem is the way that I use to read the file.
If I read the file in the following way, the problem concerning the size are bypassing.
DATA : gs_table LIKE LINE OF gt_table.
  DATA: l_xstring TYPE xstring.
  DATA : alen TYPE i.
  OPEN DATASET  p_p_file FOR INPUT IN BINARY MODE.
  IF sy-subrc EQ 0.
   DO.
    READ DATASET p_p_file INTO l_xstring.
     p_bin_filesize = p_bin_filesize + alen.
     IF sy-subrc NE 0.
       EXIT.
     ENDIF.
     APPEND gs_table TO gt_table.
   ENDDO.
  ENDIF.
  CLOSE DATASET p_p_file.
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer                = l_xstring
    APPEND_TO_TABLE       = ' '
     IMPORTING
       output_length         = p_bin_filesize
      TABLES
        binary_tab            =  gt_table .
thanks a lot
barbara

Similar Messages

  • Error while sending PDF file by Email

    Hi All,
    I have a requirement to send multiple files by Email attachement from SAP to internet address.
    All files sent correctly, except one PDF file.
    I have 2 spools, and I am using FM CONVERT_OTFSPOOLJOB_2_PDF to get PDF data for Spool.
    Then I am converting the 134 length PDF data to 255 Email Attachement binary table.
    Now I have 2 file F1.PDF and F2.PDF, in SAP Office outbox and in receivers email, F2.PDF opening fine, however for F1.PDF I am getting some error no 109 in Adobe, which says "There was an error processing a page.There was a problem reading this document. (109)".
    Please help in figuring out the reason for this.
    Additional Information F2.PDF has some text data (SAP Script output) and F1.PDF has some text data with logo (SAP Script Output)
    Thanks in advance

    hi check out following code..
    REPORT ZRICH_0003.
    DATA: ITCPO LIKE ITCPO,
    TAB_LINES LIKE SY-TABIX.
    Variables for EMAIL functionality
    DATA: MAILDATA LIKE SODOCCHGI1.
    DATA: MAILPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: MAILHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: MAILBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC LIKE SOMLREC90 OCCURS 0 WITH HEADER LINE.
    DATA: SOLISTI1 LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
    PERFORM SEND_FORM_VIA_EMAIL.
    FORM SEND_FORM_VIA_EMAIL *
    FORM SEND_FORM_VIA_EMAIL.
    CLEAR: MAILDATA, MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    REFRESH: MAILTXT, MAILBIN, MAILPACK, MAILHEAD, MAILREC.
    Creation of the document to be sent File Name
    MAILDATA-OBJ_NAME = 'TEST'.
    Mail Subject
    MAILDATA-OBJ_DESCR = 'Subject'.
    Mail Contents
    MAILTXT-LINE = 'Here is your file'.
    APPEND MAILTXT.
    Prepare Packing List
    PERFORM PREPARE_PACKING_LIST.
    Set recipient - email address here!!!
    MAILREC-RECEIVER = '[email protected]'.
    MAILREC-REC_TYPE = 'U'.
    APPEND MAILREC.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = MAILDATA
    PUT_IN_OUTBOX = ' '
    TABLES
    PACKING_LIST = MAILPACK
    OBJECT_HEADER = MAILHEAD
    CONTENTS_BIN = MAILBIN
    CONTENTS_TXT = MAILTXT
    RECEIVERS = MAILREC
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    OPERATION_NO_AUTHORIZATION = 4
    OTHERS = 99.
    ENDFORM.
    Form PREPARE_PACKING_LIST
    FORM PREPARE_PACKING_LIST.
    CLEAR: MAILPACK, MAILBIN, MAILHEAD.
    REFRESH: MAILPACK, MAILBIN, MAILHEAD.
    DESCRIBE TABLE MAILTXT LINES TAB_LINES.
    READ TABLE MAILTXT INDEX TAB_LINES.
    MAILDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( MAILTXT ).
    Creation of the entry for the compressed document
    CLEAR MAILPACK-TRANSF_BIN.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 0.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'RAW'.
    APPEND MAILPACK.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form. just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
    PERFORM GET_OTF_CODE.
    LOOP AT SOLISTI1.
    MOVE-CORRESPONDING SOLISTI1 TO MAILBIN.
    APPEND MAILBIN.
    ENDLOOP.
    DESCRIBE TABLE MAILBIN LINES TAB_LINES.
    MAILHEAD = 'TEST.OTF'.
    APPEND MAILHEAD.
    Creation of the entry for the compressed attachment
    MAILPACK-TRANSF_BIN = 'X'.
    MAILPACK-HEAD_START = 1.
    MAILPACK-HEAD_NUM = 1.
    MAILPACK-BODY_START = 1.
    MAILPACK-BODY_NUM = TAB_LINES.
    MAILPACK-DOC_TYPE = 'OTF'.
    MAILPACK-OBJ_NAME = 'TEST'.
    MAILPACK-OBJ_DESCR = 'Subject'.
    MAILPACK-DOC_SIZE = TAB_LINES * 255.
    APPEND MAILPACK.
    ENDFORM.
    Form GET_OTF_CODE
    FORM GET_OTF_CODE.
    DATA: BEGIN OF OTF OCCURS 0.
    INCLUDE STRUCTURE ITCOO .
    DATA: END OF OTF.
    DATA: ITCPO LIKE ITCPO.
    DATA: ITCPP LIKE ITCPP.
    CLEAR ITCPO.
    ITCPO-TDGETOTF = 'X'.
    Start writing OTF code
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    FORM = 'ZTEST_FORM'
    LANGUAGE = SY-LANGU
    OPTIONS = ITCPO
    DIALOG = ' '
    EXCEPTIONS
    OTHERS = 1.
    CALL FUNCTION 'START_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    WINDOW = 'MAIN'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    Close up Form and get OTF code
    CALL FUNCTION 'END_FORM'
    EXCEPTIONS
    ERROR_MESSAGE = 01
    OTHERS = 02.
    MOVE-CORRESPONDING ITCPO TO ITCPP.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    RESULT = ITCPP
    TABLES
    OTFDATA = OTF
    EXCEPTIONS
    OTHERS = 1.
    Move OTF code to structure SOLI form email
    CLEAR SOLISTI1. REFRESH SOLISTI1.
    LOOP AT OTF.
    SOLISTI1-LINE = OTF.
    APPEND SOLISTI1.
    ENDLOOP.
    ENDFORM.

  • Error in opening pdf file from mail attachment sent thru MII

    Hi,
    I am using MII 12.1.4 build(36).
    I have created a pdf file from BLS using PDF actions block and saving the file in web location as mentioned below:
    WEB://<ProjectFolder>/<subfolder>/Report.pdf
    I'm using the same file as attachment in my m a i l action block with attachment content type "application/pdf" and AttachmentContent "ImageSaver.EncodedImage" or "PDFDoc.Output".
    When i check the mail,i can see the attachment with some size of 8kb,but when I open the file i will get below error:
    "Adobe Reader could not open Report.pdf because it is either not supported file type or because the file has been damaged(for example,it was sent as an m a i l attachment and wasn't correctly decoded)"
    If I try to open the same file by exporting fit to my desktop,it opened properly.
    Anything I'm missing here?
    Thanks in Advane,
    Suresh

    Hi,
    According to below mentioned thread,this problem is fixed in 12.1.5 and above.
    Re: Attachment Content When sending PDF attachment in Send Mail Step
    Then I deployed the new patch ie SP07.
    Here there is one problem,ie in Menu page I can see the 12.1.7(Build40),when I open the workbech,it shows the previous patch 12.1.4(Build 36).Why is it so?
    All of my transactions running fine except the one which I have mentioned in my previous post.
    When I run the transaction mentioned in my previous post,it threw an excption for PDF Table Action block and the error mentioned below:
    [ERROR] Error found trying to execute action 'PDF_Table_0' Exception: [null]
    [ERROR] [PDF_Table_0] Action: Runtime threw an exception. Exception: [java.lang.StackOverflowError]
    When I can check the m a i l, I'm able to open the attached PDF file without error but without data.Is it because of the above mentioned error?
    Plz help me.
    -Suresh

  • Error  while  reading pdf file using adobe reader 8

    Hi ,
    I am using itextsharp for creating pdf file which contains 300 pages.
    When I tried to open that pdf file in adobe reader 5 , there is no issue . Its opening correctly. But When I 've tried to open it using adobe reader 8 . Its opening the file but I could read upto 156 pages out of 300. I couldn't read beyond that. Its displaying the following error message "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem" , "could not find the XObject named 'Xf2'." .
    Please help me to resolve the issue.
    Thanks,
    Tamil.

    Hi ,
    I am using itextsharp for creating pdf file which contains 300 pages.
    When I tried to open that pdf file in adobe reader 5 , there is no issue . Its opening correctly. But When I 've tried to open it using adobe reader 8 . Its opening the file but I could read upto 156 pages out of 300. I couldn't read beyond that. Its displaying the following error message "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem" , "could not find the XObject named 'Xf2'." .
    Please help me to resolve the issue.
    Thanks,
    Tamil.

  • Error during rebuilding PDF file using FM SCMS_XSTRING_TO_BINARY

    Hi,
    PDF file content is compressed and stored on a custom table within SAP. The requirement is to download this onto Unix application server directory. I am using one FM to decompress the data and another to convert into a binary format to be saved as .PDF.
    I am using FM SCMS_XSTRING_TO_BINARY to save the content as pdf file from the XSTRING data. I am getting an error message while opening such a pdf file: "Could not find the XObject named '00010' ". Also the company logo is missing from the file. I feel both are connected. does anyone know the solution for this?

    Hi,
    I have a smiliar requirement, can you please help?
    Regards
    Manu

  • Cannot send PDF file using adobe reader XI

    Hi,
    My boss tried to open PDF using adobe reader XI and by going to File -> Send Email, it will prompt with error below.
    I confirm outlook is configured as default mail program
    Windows OS is Windows 7 64bit, same issue for Desktop and Laptop.

    You are posting in the bug report section for Adobe Business Catalyst, so your posting in the wrong section so there is no one here who can help you on that.

  • HR: Need to Send the Paysilp as a PDF file through Mail to Employees

    Dear All ,
           Need to Send the Paysilp as a PDF file through Mail to Employees.
           can anyone please suggest any Standard Function Modules which takes the Payslip Form as input and convert it into PDF and can send it through mail to the concern employees.
          Can anyone please explain the procedure in detail.
    Thanks in Advance,
    Regards.

    venu,
    below is code which helps to generate pdf ,,,,hope u know how to use the mail sending function
    data:
    fm_name TYPE RS38L_FNAM, "Smart Forms: FM Name
    sf_name TYPE TDSFNAME
    value 'YOUR_FORM_NAME', "Smart Forms: Form Name
    P_OUTPUT_OPTIONS TYPE SSFCOMPOP,
    P_JOB_OUTPUT_INFO TYPE SSFCRESCL,
    P_CONTROL_PARAMETERS TYPE SSFCTRLOP,
    P_LANGUAGE TYPE SFLANGU value 'E',
    P_E_DEVTYPE TYPE RSPOPTYPE.
    data:
    P_BIN_FILESIZE TYPE I,
    P_BIN_FILE TYPE XSTRING,
    P_OTF type table of ITCOO,
    P_DOCS type table of DOCS,
    P_LINES type table of TLINE,
    name type string,
    path type string,
    fullpath type string,
    filter type string,
    guiobj type ref to cl_gui_frontend_services,
    uact type i,
    filename(128).
    GET SMARTFORM FUNCTION MODULE NAME ---
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = sf_name
    IMPORTING
    FM_NAME = fm_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.
    CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
    EXPORTING
    I_LANGUAGE = P_LANGUAGE
    I_APPLICATION = 'SAPDEFAULT'
    IMPORTING
    E_DEVTYPE = P_E_DEVTYPE.
    P_OUTPUT_OPTIONS-XSFCMODE = 'X'.
    P_OUTPUT_OPTIONS-XSF = SPACE.
    P_OUTPUT_OPTIONS-XDFCMODE = 'X'.
    P_OUTPUT_OPTIONS-XDF = SPACE.
    P_OUTPUT_OPTIONS-TDPRINTER = P_E_DEVTYPE.
    P_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
    P_CONTROL_PARAMETERS-GETOTF = 'X'.
    ****...................................PRINTING.........................
    CALL FUNCTION fm_name
    EXPORTING
    CONTROL_PARAMETERS = P_CONTROL_PARAMETERS
    OUTPUT_OPTIONS = P_OUTPUT_OPTIONS
    (....) <--- your form import parameters
    IMPORTING
    JOB_OUTPUT_INFO = P_JOB_OUTPUT_INFO.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    P_OTF[] = P_JOB_OUTPUT_INFO-OTFDATA.
    ****...................................CONVERT TO PDF...............
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
    IMPORTING
    BIN_FILESIZE = P_BIN_FILESIZE
    TABLES
    OTF = P_OTF
    DOCTAB_ARCHIVE = P_DOCS
    LINES = P_LINES
    EXCEPTIONS
    ERR_CONV_NOT_POSSIBLE = 1
    ERR_OTF_MC_NOENDMARKER = 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.
    now you can mail the pdf.
    Reward points if helpful
    Regards,
    jinesh

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

  • I have an iPad 2, and I am sending PDF file to my iPad, via a Hotmail email. But, the PDF arrives to the iPad in Mail already opended, as a picture on the bottom of the email. Is there a way to prevent it from auto open, so I can open with iBooks instead?

    I have an iPad 2, and I am sending PDF files to my iPad, via a Hotmail account. But, the PDF arrives to the iPad Mail account already opened at the bottom of the email. Is there a way to prevent this auto-opening of the PDF. I've seen screen shots with the box, and PDF listed inside the box, but mine open automatically. I want to get them into iBooks...?

    I am having the same problem and it is even bigger.
    When opening a 1-page PDF in iBooks and sending it via mail it is sent inline as preview, but the recipient cannot open the file anymore. Also on iPad and iPhone there is no "open in" possible.
    Somehow the mail app does destroy the file. What is going wrong?

  • Since I downloaded Adobe Reader 11.0.07 I have been totally unable to print any PDF files using my Dell 1720 laser printer - I just get a blinking "error" light on the printer, no other error messages . I never had a problem printing PDF files before down

    Since I downloaded Adobe Reader 11.0.07 I have been totally unable to print any PDF files using my Dell 1720 laser printer - I just get a blinking "error" light on the printer, no other error messages . I never had a problem printing PDF files before downloading the new Reader version. Suggestions? Thank you.

    Hi,
    Which version of Adobe Reader were you using earlier when printing using Dell printed was working fine?
    Thanks,
    Shakti K

  • 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

  • How to send image file through mail without   any attachment

    Plz tell  me how to send image file through mail without any attachment  ( i mean not converting  that image into pdf or any format )  i want to send that text or image  through mail .

    Hi Sandeep,
    I think you can setup the type of email in Shared office Settings in transaction S016.
    There is an option called <Preset document classes>
    You choose this pushbutton to branch to the maintenance screen for the document classes that are directly displayed to users in the Business Workplace for selection when they use the Create function. The name under which the documents are displayed can also be maintained.
    http://help.sap.com/saphelp_nw70/helpdata/en/6c/69c30f418d11d1896e0000e8322d00/content.htm
    Haven't tried it though.
    Regards,
    Siddhesh

  • Problem to send PDF file

    Hello,
    I try to send pdf file as attachments file to mail with XI.
    I use with this blog
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816
    My problems is:
    1. to all mails that I send have another e file Untiteld.doc, how I can avoid this file?
    2. When I received the pdf file I not succeed to open it I received the message:
    Adobe reader could not open 'elad.pdf' because it is either not supported
    File type or because the file has been damaged (for example, it was sent as an
    Email attachment and wasn't correctly decoded)
    Regards
    Elad Peleg

    hi
    ref this
    Receiver Mail Adapter message with PDF attachment
    PDF attachment in mail adapter
    File adapter with attachment to mail
    File with attachment to mail scenario
    File To Mail Scenario With An Attachment

  • Sending PDF files, I can't open it with Yahoo or Gmail

    Hi!!
    I'm using Central Pro ver. 5.7 on HP-UX and It generates all the invoices of the company (PDF files).
    When I send the PDF files using Central Pro to my customers, they can open it using Outlook or Hotmail, but If they want to open this email on yahoo or gmail, they can't do it.
    In Yahoo, the application tries to show the PDF file open, so, you read characters rares only.
    In Gmail, the email is empty, the attachments doesn't appears.
    Do you know why this happen??
    By the way, if I received the email from Central Pro and resend it to yahoo or gmail using Outlook, I can open the email in that applications without problems.
    Best regards

    What does Mail/Window/Connection Doctor Show? If the server is red, select it and look at the Show Details box.
    Troubleshooting sending and receiving email messages

  • 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

Maybe you are looking for

  • Is it possible to move the ldb selection screen?

    Hi All, I have a custom program which uses a logical db. The selection screen from the LDb is displayed first and then my custom selection screen is displayed. There is a requirement where the custom selection screen needs to displayed first - at top

  • Why don't you guys have a phone number so I can talk to someone? I can't summarise this in one sentence!

    I want to have Firefox as an alternative email site on my new smart phone (LG - P930 Android) but according to the phone I need the following info to set this up. Is it POP3 or IMAP account email address Protocol type POP3/IMAP4 Incoming server - ser

  • Coverflow sorting by artist...

    ... for classical music is just nonsense. No one might look primarily for an album sung by Domingo - I shall search for the title of the album, of course,, as I would in my paper box in earlier times... The side effect of splitting albums in as many

  • Help! Can't get DVD drive to play discs.

    I called Apple care. They refered me to my local Genius bar (Apple store); where they reset something but wouldn't tell me what, and it played for awhile. Now the DVD player just ejects the disc after about 15 seconds. I know I'm a dummie, but I hate

  • Exchange 5.5 portles not working

    Environment: Portal 3.0.9/W2K -> IIS/W2K -> Exchange 5.5/NT I have followed the Exchange 5.5 Portlets installation instructions and troubleshooting guide completely but the portlets still do not work. I only see the "Update Login Information" link in