Email PDF

Hi,
I'm trying to email an PDF file to an internet address.
Upon opening the PDF document I get the following error
"There was an error opening this document. The file is damaged and could not be repaired."
When downloading the same document to my desktop with GUI_DOWNLOAD it looks fine.
This is my sample code (more or less SAP's BCS_EXAMPLE_5).
Regards,
Vibeke
REPORT ztest.
* This example shows how to send
*   - a simple text provided in an internal table of text lines
*   - and an attached MS word document provided in internal table
*   - to some internet email address.
* All activities done via facade CL_BCS!
DATA: send_request       TYPE REF TO cl_bcs.
DATA: text               TYPE bcsy_text.
DATA: binary_content     TYPE solix_tab.
DATA: document           TYPE REF TO cl_document_bcs.
DATA: sender             TYPE REF TO cl_sapuser_bcs.
DATA: recipient          TYPE REF TO if_recipient_bcs.
DATA: bcs_exception      TYPE REF TO cx_bcs.
DATA: sent_to_all        TYPE os_boolean.
DATA: l_spool LIKE tsp01-rqident VALUE 6509.
DATA: it_pdf LIKE tline OCCURS 0 WITH HEADER LINE.
DATA: w_buffer TYPE string.
DATA: BEGIN OF it_buffer OCCURS 0.
DATA: line(255) TYPE c.
DATA: END OF it_buffer.
DATA: xx_pdf TYPE soli_tab.
START-OF-SELECTION.
  CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid              = l_spool
    TABLES
      pdf                      = it_pdf
    EXCEPTIONS
      err_no_otf_spooljob      = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_dstdevice        = 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.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename = 'C:ProfilerlpwDesktopfile.pdf'
      filetype = 'BIN'
    TABLES
      data_tab = it_pdf.
  LOOP AT it_pdf.
    TRANSLATE it_pdf USING '~'.
    CONCATENATE w_buffer it_pdf INTO w_buffer.
  ENDLOOP.
  TRANSLATE w_buffer USING '~'.
  DO.
    it_buffer = w_buffer.
    APPEND it_buffer.
    SHIFT w_buffer LEFT BY 255 PLACES .
    IF w_buffer IS INITIAL.
      EXIT.
    ENDIF.
  ENDDO.
  xx_pdf[] = it_buffer[].
  binary_content[] = it_buffer[].
  PERFORM main.
*       FORM main                                                     *
FORM main.
  TRY.
*     -------- create persistent send request ------------------------
      send_request = cl_bcs=>create_persistent( ).
*     -------- create and set document with attachment ---------------
*     create document from internal table with text
      APPEND 'Hello world!' TO text.
      document = cl_document_bcs=>create_document(
                      i_type    = 'RAW'
                      i_text    = text
                      i_length  = '12'
                      i_subject = 'test created by Vibeke' ).
*     add attachment to document
*     BCS expects document content here e.g. from document upload
*     binary_content = ...
      CALL METHOD document->add_attachment
        EXPORTING
          i_attachment_type    = 'PDF'
          i_attachment_subject = 'My PDF attachment'
          i_att_content_text   = xx_pdf.
*          i_att_content_hex    = binary_content.
*     add document to send request
      CALL METHOD send_request->set_document( document ).
*     --------- set sender -------------------------------------------
*     note: this is necessary only if you want to set the sender
*           different from actual user (SY-UNAME). Otherwise sender is
*           set automatically with actual user.
      sender = cl_sapuser_bcs=>create( sy-uname ).
      CALL METHOD send_request->set_sender
        EXPORTING
          i_sender = sender.
*     --------- add recipient (e-mail address) -----------------------
*     create recipient - please replace e-mail address !!!
      recipient = cl_cam_address_bcs=>create_internet_address(
                              '[email protected]' ).
*     add recipient with its respective attributes to send request
      CALL METHOD send_request->add_recipient
        EXPORTING
          i_recipient = recipient
          i_express   = 'X'.
*     ---------- send document ---------------------------------------
      CALL METHOD send_request->send(
        EXPORTING
          i_with_error_screen = 'X'
        RECEIVING
          result              = sent_to_all ).
      IF sent_to_all = 'X'.
        WRITE text-003.
      ENDIF.
      COMMIT WORK.
* *                     exception handling
* * replace this very rudimentary exception handling
* * with your own one !!!
    CATCH cx_bcs INTO bcs_exception.
      WRITE: 'Fehler aufgetreten.'(001).
      WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
      EXIT.
  ENDTRY.
ENDFORM.                    "main
Message was edited by: Vibeke Skov Baird

Vibeke,
Hi. The way you are creating the xx_pdf itab is flawed.
The below code works
Cheers
Rob
    refresh tab_pdf.
    loop at lt_pdf into lw_pdf_lines.
      move lw_pdf_lines-tdformat to lw_charline.
      move lw_pdf_lines-tdline(132) to lw_charline+2(132).
      append lw_charline to tab_pdf.
    endloop.
        perform tab_to_255 tables tab_pdf
                                  tab_soli.
        call method document->add_attachment
          exporting
            i_attachment_type    = 'PDF'
            i_attachment_subject = l_subject
        "    i_attachment_size    = l_att_size
            i_att_content_text   = tab_soli[].
form tab_to_255 tables tab_pdf
                       tab_255.
  data: l_pdf           type gtypes_pdf,
      l_attachment_long type string,
      l_attachment      type soli.
  check not ( tab_pdf[] is initial ).
Convert pdf itab to 255 line itab.
  data :lv_counter  type i.
  data :lv_from     type i.
  loop at tab_pdf into l_pdf.
    translate  l_pdf using ' ~' .
    concatenate l_attachment_long l_pdf into l_attachment_long.
  endloop.
  translate  l_attachment_long using '~ ' .
  clear : lv_counter.
  do.
    lv_counter = strlen( l_attachment_long ).
    if lv_counter ge 255.
      l_attachment = l_attachment_long(255).
      append l_attachment to tab_255.
      shift l_attachment_long by 255 places.
    else.
      l_attachment = l_attachment_long(lv_counter).
      append l_attachment to tab_255.
      exit.
    endif.
  enddo.
endform.                                                    "tab_to_255

Similar Messages

  • Email PDF file name issue via output determination - order confirmation etc

    Hi,
    I can email pdf files via output determination. Unfortunately the file name is same as sapscript name. How do I change it to the name I want for example document number.
    Thanks,
    Jai

    Hi Jaideep,
    You can change the mail title at Output determination.
    T/code NACE--> Application > Outputtype> Select O/P --> select Mail title and texts --> specify your text( with language) in "title" .
    Whenever Script send via e-mail the text you have entered will apear as mail title.
    Hope this may help you.
    Lanka

  • Adobe reader X prints email PDF attachments as english then oriental

    Using Windows XP, IE 8, Adobe Reader X and HP Laserjet 4000 printer.
    Sometimes when I print email PDF attachments from Office Outlook 2003, the attachments start printing in English and then subsequent pages turn into an oriental language (not sure which one). If I view the attachment prior to printing all the pages are clearly in English. Other times if I print the item and it is okay (in English), if I reprint it, it may start in English and then goes to the other language.
    I have not incurred anything like this in any other printing program that I use such as Word or Excel.
    I have no idea why this is happenning. Any ideas what causes this and if so how to correct this?

    Solved it!
    1-go to "edit", select Preferences.
    2-select from the left pane: Security (enhanced)
    3-click on "add folder path" button just below the big white box
    4-pick a folder of your choice and click "ok". (your selected folder path will appear in that white box above the "add folder path" button in step 3)
    5-if you want to add additional folders, just repeat steps 3 & 4
    6-once you are done, click "ok" on the preferences screen and click "ok" again to accept the changes.
    Yes, it seems illogical, but it worked.
    I tested by closing the Reader (X), then surfed the web and did what Neher5 was explaining he/she wanted to do just after opening a pdf from a website and lo-and-behold,  it worked!. No more "save to temp folder" issues.
    Hope this helps.

  • Emailing .pdf from Acrobat 9

    Hello
    I seem to be having an issue with emailing pdfs from acrobat. I am recieving an error "Acrobat is unable to connect to your email program" I am using Acrobat 9 running on a 2008r2 terminal server. The email program is Outlook 2010. All other users are able to attach a .pdf to email through adobe. Outlook is the default mapi client as i have read this is a common fix for this issue but it still does not work.

    Try clearing the profile preferences for Acrobat 9 and let them get recreate
    Repair both Acrobat and Outlook/Office
    BTW  I don't thing Windows Server 2008R2 was ever tested for Acrobat 9 on WTS.
    http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/reader/pdfs/wts_9.pdf

  • SAP version 4.7  Email pdf file that is password protected.

    Hi Gurus,
    We have a requirement:
      Email pdf file that is password protected.
      Once the user receives the email,  clicks on the attached pdf file,
         it should ask the password.  Note that Password value should come from SAP.
    What we have done is get the spool number and by using function module CONVERT_ABAPSPOOLJOB_2_PDF, it converts the spool document to pdf.
    On this function module, there are no parameters to make pdf as password protected and
      also include the password.  This is the problem.
    Question:
       (a) Is there a way to make pdf password protected that will be emailed?
            What function modules, etc to be used?  (sample coding if available)
       (b) Somebody mentioned the that Adobe LiveCycle Policy Server should be installed together with SAP.
            If this is installed, how then would be the abap coding be in order to make the pdf password
                protected?
            How is the new policy server gonna be linked to SAP and how do the abap coding gonna be?
               (sample abap coding if available)
    Thanks.
    Raymund

    hi,
    First save the file somewhere... LINK:[SITE|http://www.sapfans.com/forums/viewtopic.php?f=13&t=326228]
    In the site i send above you need to change it do receive parameters ou use always the same name...compile and then use the function 'WS_EXECUTE' - watch it in LINK: [SITE|http://www.sap-img.com/abap/ws-execute-to-call-external-program.htm]
    and then..you just have to download it again into an ITAB and send it by mail... LINK:[SITE|How to pass pdf data to ABAP itab;
    Hope it helps..

  • I cannot open PDF's from a friends new PC, to my MacBook.  All other emailed PDF's are able to be op

    I cannot open PDF's from a friends new PC, to my MacBook.  All other emailed PDF's are able to be opened.  The  attachments show up as "win mail.dat" files, that Adobe will nor open.  What can I do?

    This is due to windows encoding of the files for mailing. You need TNEF's Enough
    http://www.joshjacob.com/mac-development/tnef.php

  • How can i send emailed PDF's directly to my iPad iBooks rather than have them sitting in my inbox unorganized...

    I had hoped that my PDF's in my iPhone iBooks would automatically also go to my iPad iBooks without the need for syncing. Is there some setting to make that happen?
    If that is not an option, how can I send my emailed PDF's directly to my iPad iBooks; I no longer want them sitting in my email folder since there is no way to organize the content of the email folders and I am looking for a way to organize this information that I need to be able to quickly retrieve.

    Thank you for your rapid reply! Yes, I was able to move them from my email to iBooks on my iPhone in this way, but the same method did not work for the iPad . I was really hoping for some super simple solution... thanks for your comment though

  • In my Mac Mail Version 4.5, I am not received email pdf attachement. It is shown in some html like form in message content. Please help

    In my Mac Mail Version 4.5, I am not received email pdf attachement. It is shown in some html like form in message content. Please help

    Erdygirl please be aware you are posting to a public forum.  I have removed your personal information from your previous post.
    Please check your account at http://www.adobe.com/ to locate your serial number.  You can find more information on how to locate your serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.

  • I'm unable to email PDF attachments, this has started in the last 2 weeks - any clues why as other file types are sending?

    I'm unable to email PDF attachments, this has started in the last 2 weeks - any clues why as other file types are sending?

    Greetings,
    That is rather strange. Attachments are attachments.  The big difference between what will send and what won't is usually either who you are sending it to (wrong email address) or how big the attachment is (most email providers have a limit to the total message size between 10 MB and 20 MB).
    -- What happens when you say you are "unable to email PDF attachments"?  What error message do you get?
    -- Are you sending these emails using the Mail program?
    -- What is the file size of the PDF you are trying to send?
    -- What happens if you compress the PDF before you email it (Highlight the PDF on the desktop and then go to File > Compress) ?
    -- What happens if you send the PDF to yourself?
    Cheers.

  • Ipad 2 - email PDF attachments corrupt

    I seem to be having trouble viewing PDF's on my Ipad2.  They read fine on my iphone and my mac and my work PC.  When I "open in" any reader I have same problem.  I tried Ibooks, goodreader, notesplus, Pdf provider and so on.  I get some graphics but then blurry or blackish boxey lines where words should be written.
    I can open them in "cloud on" fine also.  Strange. 
    Any comments?

    Greetings,
    That is rather strange. Attachments are attachments.  The big difference between what will send and what won't is usually either who you are sending it to (wrong email address) or how big the attachment is (most email providers have a limit to the total message size between 10 MB and 20 MB).
    -- What happens when you say you are "unable to email PDF attachments"?  What error message do you get?
    -- Are you sending these emails using the Mail program?
    -- What is the file size of the PDF you are trying to send?
    -- What happens if you compress the PDF before you email it (Highlight the PDF on the desktop and then go to File > Compress) ?
    -- What happens if you send the PDF to yourself?
    Cheers.

  • How Do I Secure an Emailed PDF to the Recipient's PC?

    Hi All,
    How can an emailed PDF be tied to a recipient's PC so that it can only be viewed on that PC?
    I do not want to use password control or high-end 3rd party systems, e.g. FileOpen, LockLizard, etc.
    I only care about restricting access (viewing), not distribution, editing, renaming, etc.  In fact, I'd prefer that
    the secured PDF could still be edited and resaved by the recipient, just not viewable on another machine.
    Thanks for any help!

    It can't be done without using a Digital Rights Management solution (using a server and expensive software).

  • External Email (PDF Attachment) while PO is created or Changed

    Hi All,
    I have a requirement as below.
    1. When a PO is created / changed then saved, the PO Form is to be sent to the respective vendor through External Email along with the PO Form printout generated.
    2. The PO Form is to be attached in the Email (PDF Document).
    Please write to me if you have a suitable solution for this requirement.
    I have created the PO Form in SAPScript. Is it possible to develop the above requirement in SmarForm? Please suggest me.
    Thanks in Advance,
    Kannan.

    Since you are using SAPScript I thought this solution would be simpler. We are also using SAPScript and email all document types when necessary.
    1. As suggested before: create an output type as an email type (Same as mornal output just the value 8 for transmission medium).
    2. For ease of maintainance I copied the associated printing program to a new program and link this new program to the output type as normal.
    3. In your print program make the following changes.
    (a) include code below just before your open form. You can read the email address from whereever you have them. In this example they are read from a custom z* table ZEMAIL_TEMP . Sometimes we read them from customer master, vendor master etc.
    (b) make sure you have the folowing export parameter in your "START_FORM" Function module
         MAIL_RECIPIENT = RECIPIENT_OBJ
    4. Make sure your conversion rules are set properly. Transaction code SCOT Setting-->Conversion Rules
    SAPScript text is an OTF type. We are converting our forms to PDF so we have the following entry:
    Format = OTF     
    Format to = PDF
    Ranking = 1        
    Function Module = SX_OBJECT_CONVERT_OTF_PDF</b>
    5. The are other bells and whistles (like changing the email header) that I can happily share once/if you are happy with your solution.
    Hope I am not missing any vital info.
    Good Luck

  • Email PDF from Firefox -- keeps freezing

    This may belong in a Firefox forum, but thought I'd give it a shot here.
    I frequently use the Print>PDF>email PDF function from within Firefox. Recently, however, this has stopped working -- the "Printing Progress Bar" freezes, necessitating a Force Quit.
    I've checked, and the email PDF print function works in other applications, including Safari.
    I've made no changes (i.e. installed no updates) to Firefox, so I have no idea why it's started crashing.
    Any ideas?

    Just a bit more info in the event anyone is listening....
    I can do no printing whatsoever from Firefox -- PDF or to an actual printer. Printing from other applications, however, works fine.
    I've tried repairing permissions, but that didn't do fix the problem.
    Any ideas?

  • Email PDF attachements

    email PDF attachements that are open in ibooks will not close , and cant return to mail box in box

    This has happened to other users too. There seems to no solution to prevent it from happening. You can restore you iPad to service by either resetting your iPad:
    Press and hold both the Sleep/Wake button and the
    Home button for at least ten seconds, until the Apple logo appears.
    Or for some people turning of and then back on the specific Mail account in Setting does the trick.

  • How to email .pdf PO to supplier after approval?

    Hi All,
    My client has a requirement to email .pdf PO to supplier after approval of PO.
    kindly give me setup steps as to how I can acheive this through workflow.
    You can mail me setup steps to this email address: [email protected]
    Thanks,
    Younus

    The setups are detailed on a note in the following metalink note.
    FAQ: E-Mail PO Functionality [ID 307577.1]
    Basically, make sure XDO is installed, change Purchasing email option to PDF and make sure you enter an email address on po site. For details, refer to the note above.
    Hope this answers your question
    Sandeep Gandhi
    Omkar Technologies Inc.
    Independent Techno-functional Consultant
    513-325-9026

  • Rfkord11 email pdf

    hi,
    may i know how to email pdf file for customer statement in FI module via tcode f.27.
    i got the fm for pdf and also email in the include rfkori90 but do not know how to trigger it.
    any advice.
    thanks

    Well actually whatever report fomat u get just export it into PDF or excel by going into menu System ---> List -
    > Save.
    Whatever format u want save it and then mail it.
    Thanks,

Maybe you are looking for

  • Cached Podcast Password needs to be changed!

    I have a podcast that uses a password that I saved via iTunes. Now the password has changed and I cannot find any way to change the password. I tried removing the feed, then adding it again, but it appears to have cached it because it just brings up

  • 2012 Mac Mini becoming very slow when using finder

    Hi! I've had my 2012 Mac Mini (10.9 Mavericks, Dual Booted W/ Windows) since February 2014 (Late to the party, I know) and, up until about a week ago, it was fine. Then, all of a sudden, it starts being unusabley slow the moment I try to do anything

  • Multiple BPEL Process Managers in one environment?

    Hi, I'm quite new to the Oracle SOA product line, so please be gentle when my question doesn't make sense. I'm in the process of designing a new enterprise architecture based on service orientation. I'm looking at the Oracle SOA Suite software to get

  • ABC indicator transfer to sub equipments

    Hello, We use Superior and Sub equipments and we have different ABC indicators for both. However when I change ABC indicator for superior equipment, same gets transferred to sub equipments Is there a way I can stop this....I do not want data transfer

  • Error in WS client in java

    Hi I have developed one standalone java client to invoke a WS. But when I execute it gives me following error in the response. - <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"