How to attach a PDF to a mail with  document-add_attachment

Hello,
I don't know how to pass the PDF to binary, in order to be able to pass the parameter to the method add_attachment.
Exist any FM? How to make compatible this new binary file with the parameter of the method?
      document->add_attachment(
                      i_attachment_type = 'PDF'
                      i_attachment_subject = 'attachment'
                      i_att_content_hex = ???? ).
Thank you,
Manel

Hi,
Follow example here.
DATA: l_doland1 TYPE char255,
        l_doland2 TYPE char255.
Preparing body of the Mail
  MOVE 'Please Find the Attached Packlist' TO l_text.
  APPEND l_text TO i_content.
Preparing contents of attachment with Change Log
  PERFORM prepare_attachment.
Creates persistent send request
  TRY.
      l_send_request = cl_bcs=>create_persistent( ).
Creating Mail Subject
  CONCATENATE '(' 'DO#' vbpla-vbeln  INTO l_doland1.
  CONCATENATE vbpla-land1 ')' '-' 'Packlist'  INTO l_doland2.
  CONCATENATE 'PreAlert from ATSG' l_doland1 'TO' l_doland2
                                      INTO l_subject separated by space.
  MOVE l_subject TO   i_subjec.
Creating Document
      l_document = cl_document_bcs=>create_document(
                                    i_type  = 'RAW'
                                    i_text  = i_content[]
                                    i_subject = i_subjec ).
Size of PDF Document
      l_size = l_byte_count.
Adding Attachment
      CALL METHOD l_document->add_attachment
        EXPORTING
          i_attachment_type    = c_ext
          i_attachment_size    = l_size
          i_attachment_subject = 'Packing List'
          i_att_content_hex    = i_attachx[].
Add document to send request
      CALL METHOD l_send_request->set_document( l_document ).
Get Sender Object
      l_uname = sy-uname.
      l_sender = cl_sapuser_bcs=>create( l_uname ).
      CALL METHOD l_send_request->set_sender
        EXPORTING
          i_sender = l_sender.
E-Mail
  SELECT * FROM zsdshpalertlist INTO TABLE email_list
                                WHERE kunnr = vbpla-kunwe.
  LOOP AT email_list.
    CHECK NOT email_list-email IS INITIAL.
    ld_email = email_list-email.
    l_recipient = cl_cam_address_bcs=>create_internet_address( ld_email ).
      CALL METHOD l_send_request->add_recipient
        EXPORTING
          i_recipient  = l_recipient
          i_express    = 'U'
          i_copy       = ' '
          i_blind_copy = ' '
          i_no_forward = ' '.
  ENDLOOP.
*Trigger E-Mail immediately
      l_send_request->set_send_immediately( 'X' ).
      CALL METHOD l_send_request->send( ).
      COMMIT WORK.
    CATCH cx_document_bcs INTO l_bcs_exception.
    CATCH cx_send_req_bcs INTO l_send_exception.
    CATCH cx_address_bcs  INTO l_addr_exception.
  ENDTRY.
FORM prepare_attachment .
  DATA: wa_pdf TYPE tline,
        wa_attachx TYPE solix,
        l_pdf_len TYPE i,
        l_con_len TYPE i,
        l_pdf_pos TYPE i,
        l_con_pos TYPE i,
        l_spool_size TYPE sood-objlen.
  FIELD-SYMBOLS: <fs_con> TYPE x.
  l_con_pos = 0.
  DESCRIBE FIELD wa_pdf LENGTH l_pdf_len IN BYTE MODE.
  DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
  LOOP AT i_pdf INTO wa_pdf.
    ASSIGN wa_pdf TO <fs_con> CASTING.
    CHECK sy-subrc EQ 0.
    DO l_pdf_len TIMES.
      l_pdf_pos = sy-index - 1.
      IF l_con_pos = l_con_len.
        APPEND wa_attachx TO i_attachx.
        FREE wa_attachx.
        l_con_pos = 0.
      ENDIF.
      MOVE <fs_con>l_pdf_pos(1) TO wa_attachx-linel_con_pos(1).
      ADD 1 TO l_con_pos.
    ENDDO.
  ENDLOOP.
  IF l_con_pos > 0.
    APPEND wa_attachx TO i_attachx.
  ENDIF.
ENDFORM.

Similar Messages

  • How to attach Multiple attachments to single mail

    How to attach multiple pdfs to single mail  ?
    or
    how to attach one pdf & One excel & One word document to single mail ?
    Thanks In Advance

    Hello Karunya,
    Please refer to the link below.
    https://wiki.sdn.sap.com/wiki/display/Snippets/Send%20email%20with%20multiple%20zipped%20attachments
    Regards,
    P Bansal

  • Can any one tell me how to attach a pdf file to the mail through workflow

    I have a smart which i am able  to convert it to a pdf file...now.. can any one tell me how to attach a pdf file to the mail through workflow

    Hi,
    To create the task for attachment
    Use the BOR SELFITEM and method NOTES_APPEND.
    The out come of this task contain a link called attachment with a clip attached. Clisk on that icon and choose the type of attachment u want . RAW , EXCEL , TXT , PDF... Then using the import icon u can attach the document u like.
    But the TYPE : OBJ.
    Similarly using NOTE_DISPLAY method u can display the documents u like.
    In any work item u have the facility to attach any atttchment for further circulation .
    Attchment @ WORKITEM
    1.Click the workitem for which you want to create the attchment
    2.Press create attachment
    3. Add the attachment u like (PDF)
    Reward points for useful answer.
    Richard A

  • How to attach a file to the mail

    How to attach a file to the mail

    I know that this can be done when going to any PDF program and push (send as  email)
    This also can done with multiple files or even with separate pages from that PDF file (Many programs can do that, like: PDF expert, Adobe Reader, iBooks, PDF Provider, Documents, etc)
    But what if I begin to wright an email, then I wanted to attach a file (such as PDF, or word, or any file) , FOR BASIC APPLE MAIL IT IS UNAVAILABLE
    You can attach Photo or Video but not PDF or other document
    There are some email programs that can attach files to email such as my.mail (as you can see from the photo)
    But why Apple don't provide such simple service ???

  • How to attach a PDF document to work item .---urgent

    Hi EXperts ,
      I am wanted to know how to attach a PDF document to my work item which i will be geneating . Pls let me the Method coding to be done so that I can send the attachment also when the work item is generated ..
    What is need to pass to Workflow container ...
    Regards
    Abhilash

    Ah ok,
    then the only way I know is to get hold of some one with skills in Smart Forms, and alley up with them. Or better yet, use it as an excuse to learn to do it your self
    With a Smart Form, you can parse data into it, create the file, and then use the GOS functionality to attatch it to your BO. All this in back ground!
    Kind regards
    Mikkel

  • How to attach a PDF file TO the form so that recipients can access the file as a resource?

    How to attach a PDF file TO the form so that recipients can access the file as a resource?

    Sorry we do not support this. What you can do though is add a Formatted Text element and add a link to a PDF. To insert a link add some text, select the text and right click on the text (or look under the Insert menu in the top right of the scene)
    Gen

  • How to attach a file to a mail in iPad

    How to attach a file in my mail in iPad

    You cannot. The Attach code in browsers means let user browse file system. You cannot access the file system, therefore the mobile version of Safari doesn't allow it.

  • I have received an attachment in my MAC OSX mail with an .wpd extension; how can I open it?

    I have received an attachment in my MAC OSX mail with an .wpd extension; how can I open it?

    Have you tried double-clicking on the file? If so what happened?
    I believe you have a Word Perfect document, so you would need an application that can open such files. You might try the free Libre Office.

  • How can I read pdf files from LabVIEW with different versions of Acrobat reader?

    How can I read pdf files from LabVIEW with different versions of Acrobat reader?
    I have made a LabVIEW program where I have possibility to read a PDF document.  When I made this LabVIEW program it was Acrobat Reader 5.0.5 that was installed on the PC. Lather when the Acrobat Reader was upgraded to version 6.0, there was an error when VI tries to launch the LabVIEW program. And Later again when we upgraded to Acrobat Reader 7.0.5 I must again do some changes and rebuild the EXE files again
    It isn't so very big job to do the changes in one single LabVIEW program, but we have built a lot of LabVIEW programs so this take time to due changes every time vi update Acrobat Reader. (We have build EXE files.)
    The job is to right click the ActiveX container and Click "Insert ActiveX Object", then I can brows the computer for the new version of acrobat Reader. After this I must rebuild all the "methods" in the Activex call to make the VI executable again.
    Is there a way to build LabVIEW program so I don't have to do this job every time we update Acrobat Reader?
    This LabVIEW program is written in LabVIEW 6.1, but I se the problem is the same in LabVIEW 8.2.
    Jan Inge Gustavsen
    Attachments:
    Show PDF-file - Adobe Reader 7-0-5 - LV61.vi ‏43 KB
    Read PDF file.jpg ‏201 KB
    Show PDF-file - Adobe Reader 5-0-5 - LV61.vi ‏42 KB

    hi there
    try the vi
    ..vi.lib\platform\browser.llb\Open Acrobat Document.vi
    it uses DDE or the command line to run an external application (e.g. Adobe Acrobat)
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"

  • How to print a pdf without user interaction (With C#)

    My boss assigned me a task that to get the ImagePreview of 1st page of PDF.
    My thought is to print the 1st page of PDF to file(virtual print to file), and get the image source, but there comes the problem:
    How can print a pdf without user interaction(With C#),question are these:
    1. I can use the ShellExcute but cannot assign the destination of output file.
    2. User interface is unwanted, I don't want show anyone the Acrobat Reader interface who click the file just want to get a preview.
    3. No place to put those parameters in.
    This problem confused me a lot of days, I wish someone can give some hints.
    Thank you very much!
    (Maybe you will tell me to use Acrobat SDK, please don't, I'm afraid we cannot afford that)

    >I have not read the document yet
    This is the first step. There are many documents, but start with the
    introductory/getting started material.
    > with a index.pdx
    A PDX is a search database to allow you to do fast searching in
    Acrobat.
    >
    >About the relationship between Adobe Reader and Acrobat, as far as I know is that, the previous one is just the reading tool for PDF document, instead, Acrobat can modify and resave the PDF doc. Is it right?
    Effectively, yes. But the Acrobat SDK is mainly for working with
    Acrobat. It's very important to keep this clear, since you have said
    you only have the free Reader, so 95% of what is in the SDK cannot
    work for you.
    >
    >Simply my questions,
    >1. I don't know which dll to refer in the .Net project to print with. Is the ActiveX folder in product folder?
    Simply, there is no point asking these questions, yet, because you
    have not started on the documentation.
    But let's continue in the SDK forum, where I have posed what seems to
    be a very important question about why print to file at all.
    Aandi Inston

  • How can I use pdf pack to convert cubase documents  (music scores)  into pdfs? I am looking for the former possibility to install acrobat like a printer but i don't have this option with "pdf pack". Can you help?

    How can I use pdf pack to convert cubase documents  (music scores)  into pdfs? I am looking for the former possibility to install acrobat like a printer but i don't have this option with "pdf pack". Can you help?

    Hi mariab,
    What format are those music scores (I'm not familiar with cubase documents). But, it may be that Adobe PDF Pack doesn't support that format. In that case, Acrobat is the way to go. You can then print your files to PDF as you'd like. You're welcome to try Acrobat for free for 30 days to see whether it's going to work for you. If you decide it is, and you'd like to use it going forward, you could convert your PDF Pack subscription into an Acrobat subscription.
    Best,
    Sara

  • How do you overlap PDF's and finish with one PDF file? Need help ASAP

    how do you overlap PDF's and finish with one PDF file?
    Need help ASAP

    I'm not sure if you can do that with CreatePDF.  Try it; you got one free use when you sign up with Acrobat.com
    If not, you will have to use Adobe Acrobat; there is a full-use 30 days trial.

  • How do i convert pdf file in editable word document

    How do i convert pdf file in editable word document ?

    To convert a PDF file to Word or Excel, you can subscribe to one of Adobe's services (Adobe ExportPDF or Adobe PDF Pack) or you can purchase Adobe Acrobat.

  • How to Attach a pdf file which is created in EP while sending the mail

    Hi guys,
    My scenario is, " A form is created in the EP and a HR person give the input/mandatory field employee number in that form so he gets the details of the employee and he edit some of the fields in the form and he gives his comments, then he press "submit" button."
    Note: The edited fields are not stored in any table.
    At this point my workflow will trigger using the event "POSITIONCHANGE" using the business object "BUS1065". Now i have to send a notification to 5 persons along with the pdf form as a attachment which is created by the initator in a display mode.
    My Questions are:
    1. How can i get that pdf form which is created by the intiator in EP to my workflow.
    2.Then how can i attach this form in the mail.

    I got the pdf into my workflow in a binary data and i passed this binary data to the function module so_document_attacthment_ap1.
    in that i am specifing that the file type is .pdf and i received mail with the pdf attachment too.

  • Attaching all PDFs in one mail? Having only one Body

    Dear All,
    I managed to develop a code which enable me to send a mail for each selected line in my table. The problem is it send to me for each line  a separate E-mail "each line has a PDF ". I just want to send only one mail for all PDFs attachments.
    Code:
    foreach (vw_CustLedgerEntryItem1 item in _ItemsList.SelectedItems)
    //you would normally process each row
    //but here we're just concatenating the properties as
    //proof that we are processing the selected rows
    //vw_CustLedgerEntryItem1 entryItem = this.vw_CustLedgerEntry.SelectedItem;
    InvSendbyMailRequestBody reqBody = new InvSendbyMailRequestBody(
    item.Document_No_
    , item.Report_Type
    , "DynNavHRS"
    , this.Application.User.Name.Replace(@"HRS\", "") + "@hrs.com" // HRS001
    , "Document"
    , false
    , false
    , this.vw_CustomerItem.ISO_Code // Change 7.8.2014 Bug in Email body text sprache
    , this.vw_CustomerItem.Salesperson_E_mail // Change 7.8.2014 Bug in Send E-mail
    , item.Customer_No_.ToString()
    , false
    , "XYZ"
    , false);
    InvSendbyMailRequest req = new InvSendbyMailRequest(reqBody);
    HRSReportServiceSoapClient wsHRS = new HRSReportServiceSoapClient();
    wsHRS.InvSendbyMailAsync(req);
    this.ShowMessageBox("Your email was successfully sent");
    any idea how can I send the attachment only in one mail ? My guess is that I have to take out this part out of my loop ? but its not working :(
    InvSendbyMailRequest req = new InvSendbyMailRequest(reqBody);
    HRSReportServiceSoapClient wsHRS = new HRSReportServiceSoapClient();
    wsHRS.InvSendbyMailAsync(req);
    Thanks a lot,
    Zayed

    HI Zayed,
    If you want to send an email with attachments in Lightswitch, you could consider using System.Net.Mail with
    Attachment Class. For example:
    attachment1 = pathToFirstAttachmentFile;
    attachment2 = pathToSecondAttachmentFile;
    // create and add first attachment to collection
    Attachment data = new Attachment(attachment1, MediaTypeNames.Application.Octet);
    m_MailMessage.Attachments.Add(data);
    // create and add second attachment to collection
    Attachment data2 = new Attachment(attachment2, MediaTypeNames.Application.Octet);
    m_MailMessage.Attachments.Add(data
    Best regards,
    Angie
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • 1st of the Quarter for yesterday.....

    Morning everyone, I need to write a bit of code that will retrieve the first day of the quarter, based upon yesterday's date (ie 1st of the Q for yesterday would be 01/04/2007). I have managed to achieve this using the following code: select case to_

  • Third party tool link for EDI 810

    Hi,   What is the third party tool for mapping EDI 810 and link. Thanks avi

  • Business Objects Universe Designer access error

    Hi I am getting below error when trying to access Business Objects Universe Designer XI 3.1 SP2. This application has failed to start because the application configuration is incorrect.Reinstalling the application may fix this problem. What would  be

  • Create a Script Task in c# against Sql Serveur 2008 R2

    Hello, I am trying to create a package with C#,I having issues to create the script task.My code is : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.SqlServer.Dts.Ru

  • LR4 external editor

    LR4 defaults to CS6 beta and will not let me select CS5.  What to do? Mike