Printing name of attachment in e-mail body

I'm looking for a way to print the file name of an attachment that arrives in the Mail app. We can print the attachment and the email but the name of the attachment is not printed.

Hello, and welcome to the Discussions.
Do you mean routinely, or for one special message?
Ernie

Similar Messages

  • Dynamic name for attachment in the Receiver Mail Communication Channel

    Hi All,
    I want to dynamically set the name of attachment in receiver mail Communication Channel.
    Example: IN__9907211000004_4048454000005_20081211_01000000002643
    The first two numbers 9907211000004 & 4048454000005 I want to read it from the message
    20081211 this is the date and
    And againg this number 01000000002643 is read from message.
    What is the procedure to create Adapter Module? I am new to Adapter Module.
    Any Ideas ideas?
    Thank You,
    Mukhtar

    Hi Michal,
    I had a look to your blog and tried to modify according to my requirement.
    Here is the code
    import javax.ejb.CreateException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import com.sap.aii.af.mp.module.*;
    import com.sap.aii.af.ra.ms.api.*;
    @ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>
    @ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>
    @ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>
    @ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>
    @stateless
    public class SetAttachmentName implements SessionBean, Module{
         private SessionContext myContext;
         public void ejbRemove() {
         public void ejbActivate() {
         public void ejbPassivate() {
         public void setSessionContext(SessionContext context) {
              myContext = context;
         public void ejbCreate() throws CreateException {
    public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
                          throws ModuleException{
         try {
    Message msg = (Message) moduleData.getPrincipalData();
    //creating parsable XML document
    InputStream XIStreamData = null;          
    XMLPayload xmlpayload = msg.getDocument();
    XIStreamData = xmlpayload.getInputStream();
    DocumentBuilderFactory  docBuilderFactory = DocumentBuilderFactory.newInstance();               
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.parse(XIStreamData);
    //finding the tag's name from the Modules tab in the Directory that will hold the attachment's name
    String SenderIDTag = null;
    SenderIDTag = moduleContext.getContextData("SenderIDTag");
    //finding the content of the tag that will be used as the attachment's name (assuming it's the only tag with this name)
    Element element = doc.getDocumentElement();     
    NodeList list = doc.getElementsByTagName(SenderIDTag);
    mailFileName += "_" + list.item(0).getFirstChild().toString();
    String anIDTag = null;
    ReceiverIDTag = moduleContext.getContextData("ReceiverIDTag");     
    element = doc.getDocumentElement();     
    list = doc.getElementsByTagName(ReceiverIDTag);
    mailFileName += "_" + list.item(0).getFirstChild().toString();
    Date date= new Date(System.currentTimeMillis());
    //Add date to the Message
    SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMdd");
    mailFileName += "_" + dateFormat.format(date);
    String BillNrTag = null;
    BillNrTag = moduleContext.getContextData("BillNrTag");     
    element = doc.getDocumentElement();     
    list = doc.getElementsByTagName(BillNrTag);
    mailFileName += "_" + list.item(0).getFirstChild().toString();
    //creating the attachment
    byte by[] =  xmlpayload.getText().getBytes();
    XMLPayload attachmentXML = msg.createXMLPayload();
    attachmentXML.setName(mailFileName);
    attachmentXML.setContentType("text/pdf");
    attachmentXML.setContent(by);
    //adding the message to the attachment
    msg.addAttachment(attachmentXML);
            inputModuleData.setPrincipalData(msg);
        } catch (Exception e) {
            throw new ModuleException(e);
        return inputModuleData;
    I hope this is right Adapter Module coe for my requirement.
    Thank you in Advance,
    Mukhtar

  • Retrieval of attachment filename - receiver mail adapter

    Hi,
    I am using the mail adapter to receive an e-mail into PI. This e-mail has an attached CSV file.
    First, I am using the PayloadSwapBean to swap the application playload to the attachment payload
    Second, I am using the MessageTransformBean to transform the CSV file into an XML document
    These are both working fine and the message is then passing into the relevant message mapping.
    However, I would like to be able to use the attachment filename in the message mapping.
    Can anyone advise how to do this for the mail adapter ?
    I've done it loads of times for the file adapter but never the mail adapter (when using attachments) so I am a bit stumped.
    Any advice greatly received.
    Cheers
    Colin.

    Hi Progirl,
    I want to dynamically set the name of attachment in receiver mail Communication Channel.
    Example: IN__9907211000004_4048454000005_20081211_01000000002643
    The first two numbers 9907211000004 & 4048454000005 I want to read it from the message
    20081211 this is the date and
    And againg this number 01000000002643 is read from message.
    I read from your response. You had created adapter module for the similar purpose. Can you share it. Since I am new to  writing Adapter Module.
    Thank You in Advance.
    Mukhtar

  • Mail Notification with Custom Subject, Mail Body and PDF File Name

    I have successful configured the Action Profile to send SmartForm Mail as PDF. But i would like to modify the Subject, PDF File Name & add text to mail body when a mail is sent to the user.
    The Subject of the Mail is the same as the PDF file name. How to maintain a pre-defined file name for the PDF file.

    I was able to find a commercial product that works very well. MaxBulk Mailer from Max Programming allows you to import a list of recipients, merge with personalized message and designate an attachment (just image types and PDFs, not all types work) and send.

  • Dynamic file name as mail attachment in receiver Mail Adapter?

    Hi,
    Can any one tell the possibility of attaching file as a mail attachment without using mail Package with dynamic filename.
    Business requirement is to send error response as mail attachment with dynamic name.
    Ex: Error_Response_20110802_13.24 where 20110802 is Date and next part represents time stamp.
    File attachment name should change dynamically in Mail receiver Adapter. Thanks
    Regards,
    Sreeramulu Konjeti.

    there is no standard way.
    you will have to write a module to get this in place.
    other ways are;
    XI Mail Adapter: An approach for sending emails with attachment with help of Java mapping - /people/stefan.grube/blog/2007/04/17/xi-mail-adapter-an-approach-for-sending-emails-with-attachment-with-help-of-java-mapping
    Dynamic name in the mail attachment - pseudo "variable substitution" :
    /people/michal.krawczyk2/blog/2006/02/23/xi-dynamic-name-in-the-mail-attachment--pseudo-variable-substitution

  • How to get the name of the attachment in Sender Mail Adaper?

    hi mates,
    I've scenario a where in I need to pick up a mail with an attachment and change its extension and send it to target system using file adapter.
    I'm able to pick up the mail with attachment using sender mail adapter but not able to get the name of the attachment so that I can use it in mapping or on the adapter configuration. How do I read the name of the attachment and manupulate it?
    I looked at the thread sender mail adapter - attachment name But the solution is not described. I think Stefan is talking about the SP!2 for PI 7.0. I'm on XI 3.0 what is the equivalent SP for that, SP20? Stefan, can you please throw me more light on it?
    I appreciate your valuable inputs
    thx in adv
    praveen

    Thanks Aamir.
    Earlier I replied to that thread asking for more details...but did not see the response...
    anyways, thanks for your quick help..
    but I wonder abt the PI SP12/ XI SP20 pre-requisite. We can have adapter modules on SPs lower than PI SP12/XI SP20 as well, can we not?
    thanks
    praveen

  • Mail Adapter Use Mail Package, Mail Body and Attachment

    Hello
    Have some body a idea, how I can configure the mail adapter with use mail package, that I have in the mail a attachment with content from the messages and a mail body with also text from the message.
    Thanks for your reply.
    Regards Tom
    The different Weblog , I have check:
    /people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
    https://www.sdn.sap.com/sdn/weblogs.sdn?blog=/pub/wlg/1685 [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]
    /people/michal.krawczyk2/blog/2005/03/07/mail-adapter-xi--how-to-implement-dynamic-mail-address

    Hi Thomas,
    If you are configuring your Mail adapter as reciever then refer
    http://help.sap.com/saphelp_nw04/helpdata/en/6b/4493404f673028e10000000a1550b0/content.htm
    your sender (say file) should have some message like this
    <i>
    <ml:Mail xmlns:ml=’http://sap.com/xi/XI/Mail/30’>
       <Subject>Important</Subject>
       <From>[email protected]</From>
       <To>[email protected]</To>
       <X_Mailer>Outlook Express </X_Mailer>
       <Content>
       This is the content.
       </Content>
    </ml:Mail></i>
    And for Sender Mail Adpater
    http://help.sap.com/saphelp_nw04/helpdata/en/23/c093409c663228e10000000a1550b0/content.htm
    Hope this will be helpful
    Regards
    Suraj

  • Mail makes new name for attachment

    When I send an word (or pdf) attachement to somebody, Mail changes the name. When it is a word document the name changes from "xxxx.doc" into "xxxx.dococ" and a pdf-file from "yyyy.pdf" into "yyyy.pdfdf". The recipient can not read the document. Does anybody knows what to do?

    Same problem... make me feel really unprofessional for my custommer...
    Here is what is written in the help file of the Mail Attachments Iconizer :
    File name extensions are corrupted.
    This is a bug in certain versions of Mac OS X unrelated to Mail Attachments Iconizer. When there are non-ASCII characters (e.g. ä, é or ®)™ in the file name Mail often corrupts the file name extension (e.g. .pdf, .jpg or .doc) which is often necessary to determine the file type.
    Workaround: The bug seems to be fixed in the recent Mac OS X updates (as of version 10.5.4). Additionaly it is more safe in general to only use ASCII characters in attachment file names. (ASCII characters include unaccented letters of the Latin alphabet, digits, basic punctuation and spaces.)
    I removed the "é" in the file name and it has worked... hope I don't get the problem again... and hopefully the bug will be corrected in further version... (I have Mac OS X 10.5.5 and still have the bug...)

  • Receiver Mail Adapter - Mail body as attachment

    Hello friends,
    I have scenario = File -> XI  -> Mail
    The scenario is working but the problem is body of the email is coming as attachment in the mail client.(outlook express)
    Is there any way to avoid the body coming as attachment.
    Regards
    Ramesh P

    Hi Ramesh,
    You can use the MessageTransformBean in the receiver mail adapter for this.
    Refer this for the parameters which you can use
    http://help.sap.com/saphelp_nw04/helpdata/en/57/0b2c4142aef623e10000000a155106/content.htm
    Regards,
    Chandra

  • Hp 200 wireless printer does not print the shared attachment only body of the email

    In the past I have been able to share an email with the printer and the attachment was printed. Suddenly only the body of the email prints but no attachment. Would also like to know whether one can suppress the printing of the body of the email and print only the attachment. Don't want to waste paper.

    Thanks for that additional information @Karl3.  
    I have a few suggestions that may resolve your ePrint issue.  It is possible to print attachments using the ePrint via email method, but results may vary.  At times, the formatting of an attachment is lost when using this method or at worst, it will not print.  
    As it's clear your PDF document is not printing using this approach, I recommend downloading and installing the HP ePrint app - click here to do so.  
    You'll see that it's geared towards Android users, however, if your Blackberry Z10's software is up-to-date, this app should work for you.  Once installed, you'll be able to launch the ePrint app and print directly from files and documents saved to your device.  With this interface you have greater control over what comes out of the printer.  
    With respect to your query about eliminating the extra pages that result from your phone's email signature, click here for instructions on how to turn off your email signature.  If you swipe Auto Signature off as indicated in Blackberry's forum, this should ideally stop the undesired signature page from accompanying all ePrint attachment jobs.  If the ePrint app doesn't work out for you, see if printing with the signature off yields a better result.  Keep in mind when you're sending ePrint jobs to your printer via email that you need to have something in the subject line.  
    Please let me know the result of your troubleshooting by responding to this post.  Best of luck!  
    E-roq
    I work on behalf of HP.
    Please click Accept as Solution if you feel my post solved your issue, it will help others find the solution.
    Click Kudos Thumbs Up on the right to say “Thanks” for helping!

  • Mail body as attachment in email

    Hi,
    whenever we are sending mails through the FM SO_DOCUMENT_SEND_API1 the text in the body is going as text attachment in the mail. This problem is occuring when the mail is viewed in outlook , in the business workplace the mail is looking good (body as body only).
    Please let me know if anyone has encountered this problem and has the solution? 
    Thanks,
    Rajinikanth G

    Hi Rajnikanth,
    If my understanding is correct..
    please check the code in the below perform
    perform send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
    form send_file_as_email_attachment tables pit_message
                                              pit_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.
      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[] = pit_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'
           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.
    regards,
    gowri

  • E-mail printing not printing e-mail body

    Hi,
    When using e-mail printing, e-mail body will not print, some printers printed out only codes, some a blank page with "[{" at top of page.
    Rendering service works and Word and PDF attachments printed out fine.
    Any ideas?
    Thanks,

    lchen,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • E-mail body getting converted to .txt attachment

    Hello All,
    Below is the description of the issue: -
    1) Smartform is sent as .pdf attachment in the mail along with some text in the email body, using the FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    2) Initially, the entire process was working fine.
    3) However recently, there is a problem while sending the email. Whenever we are sending the email, the text in the email body is automatically converted into .txt attachment rather than being sent in email body.
    4) There are no code changes which are done, have verified that.
    5) I copy pasted the same code, in another system and the email is sent correctly with email body.
    So wanted to know the following  :-
    1) So is the conversion of email to .txt file due to some script running on the server / is this due to some configuration.
    2) If it is due to some configuration, then where is this configuration maintiained ?
    3) Anything which can be done on the ABAP side to control this ?
    Regards,
    Rinkesh Doshi

    Hello All,
    I have identified the root cause of this problem.
    The issue is due to the configuration maintained in transaction SODIS, which is the transaction to add disclosures to the outgoing emails.
    If the standard disclosure is activated over here, the original email body is sent as text attachment and the standard disclosure is added in the email body. If we deactivate this disclosure functionality, the process works perfectly fine.
    (This logic is included inside the class CL_SEND_REQUEST_BCS, method ADD_DISCLOSURE_TO_MIME).
    So is this standard functionality error ? I could not find SAP notes which are relevant in above context.
    Regards,
    Rinkesh Doshi

  • Maverick Mail Printing Problem: prints email header on separate page from body of email.  Why?!

    Maverick Mail Printing Problem: prints email header on separate page from body of email.  Why?!

    For what it's worth, I can report exactly the same problem.  I just recently converted from Outlook for Mac 2011 to Mail.  I did the conversion while running Yosemite.  I like pretty much everything about Mail EXCEPT that it take 2 pages to print a 1 page email!!  The header appears on the top of p.1, followed by a blank space.  The message begins at the top of p.2.
    If you scale it down, you can get the message to begin to appear on the bottom of p.1, but clearly, Mail is inserting BIG SPACE between the header and the message.  Changing the display fonts for Mail had no apparent effect (except that the font DID change, of course)....still a BIG SPACE between the header and the message. 
    Coming to Mail for the first time, I would have assumed that this was just a quirk of Mail, but am I understanding that some of you Mail users out there USED TO NOT have this problem??  I think it's pretty clear that it's Mail that's causing the problem, not the message, because I went over to my old Outlook and printed the same couple of messages with no such space between the header and the message.  So Mail is inserting a space into the print formatted email message that is NOT there in Outlook's print formatted same message.
    Be really nice to get rid of this problem, but my Apple Care free support has expired.  Not sure I want to pay for something that's generic to Mail!!  Anyone else made any progress on this?

  • Sending DMS Document as Attachment thru e-mail

    Hi,
    I am attaching the DMS document in purchase order & I am sending the PO thru email to vendor.But while doing so the attached document shuld be sent as attachment But in my present config setting it is not doing so.
    Pl suggest
    Rgds

    Hi,
    With my solution you will be able to send the PO and all link document in a mail at the same time you print it.
    First Step
    Create a new message with transaction NACE , this message will use support 8 ( external program) . The print program should be a copy the same as for printing your PO but add a new form entry inside.
    Second step .
    In the print program , create the new form entry and add the code . bellow a sample code i wrote . Some object are specific so you have to create it . If you need i can give you te detail of thoses objects.
      DATA : bin_file       TYPE xstring ,
             bin_filesize   TYPE i ,
             w_objky        TYPE objky,
             my_sender      TYPE zcl_send_mail=>ty_sender,
             mail_line      TYPE LINE OF soli_tab,
             w_attsub       TYPE so_obj_des.
      DATA: l_druvo TYPE t166k-druvo,
            l_nast  TYPE nast,
            l_from_memory,
            l_doc   TYPE meein_purchase_doc_print.
      DATA : v_parvw2   TYPE nast-parvw,
             v_parnr2   TYPE nast-parnr,
             v_lifnr    TYPE konv-lifnr,
             v_adrnr    TYPE lfa1-adrnr,
             st_address TYPE addr1_sel,
             st_sadr    TYPE sadr.
    * definition des tables internes
      DATA : it_otf   TYPE STANDARD TABLE OF itcoo ,
             it_line  TYPE STANDARD TABLE OF tline ,
             it_fill  TYPE STANDARD TABLE OF drad,
             it_new   TYPE STANDARD TABLE OF drad ,
             itb_xtkomv TYPE STANDARD TABLE OF komv WITH HEADER LINE,
             itb_xekpo  TYPE STANDARD TABLE OF ekpo WITH HEADER LINE,
             it_ekpo  TYPE HASHED TABLE OF ekpo WITH UNIQUE KEY ebeln ebelp ,
             it_draw  TYPE HASHED TABLE OF draw WITH UNIQUE KEY dokar
                                                                doknr
                                                                dokvr
                                                                doktl ,
             it_drat  TYPE HASHED TABLE OF drat WITH UNIQUE KEY dokar
                                                                doknr
                                                                dokvr
                                                                doktl
                                                                langu,
             my_attachement_list TYPE zcl_send_mail=>attachement_list,
             my_recipient_list   TYPE zcl_send_mail=>recipient_list  ,
             it_hexa TYPE solix_tab ,
             it_body TYPE soli_tab.
      CONSTANTS : c_object TYPE dokob VALUE 'EKPO' .
      FIELD-SYMBOLS : <ekpo>   TYPE ekpo,
                      <drad>   TYPE drad ,
                      <draw>   TYPE draw,
                      <drat>   TYPE drat .
      DATA : my_mail TYPE REF TO zcl_send_mail . => Specific object
    ** Here write your own code like you print the PO form in order to be able to retrieve it from memory
    ** don't send it to the printer only in spool .
    * Get OTF from Memory.
      CALL FUNCTION 'READ_OTF_FROM_MEMORY'
        EXPORTING
          memory_key   = nast-objky
        TABLES
          otf          = it_otf
        EXCEPTIONS
          memory_empty = 1.
      CHECK sy-subrc EQ 0.
    * Transform OTF into PDF
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = bin_filesize
          bin_file              = bin_file
        TABLES
          otf                   = it_otf
          lines                 = it_line
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4.
    * Transform PDF as Binary Table
      it_hexa = cl_document_bcs=>xstring_to_solix( ip_xstring = bin_file ).
    * Add PO as PDF file to the mail
      zcl_send_mail=>add_attachement_to_list(
        EXPORTING
          type                       = 'PDF'
          subject                    = 'PO'
          content_hexa               = it_hexa
        CHANGING
          attachement_list           = my_attachement_list
        EXCEPTIONS
          no_content_for_attachement = 1
          no_application_type        = 2 ).
    * Get PO Item because DIR are link to item only.
      SELECT * FROM ekpo
        APPENDING CORRESPONDING FIELDS OF TABLE it_ekpo
        WHERE ebeln = nast-objky.
    * Search for DIR .
      FREE : it_draw , it_drat .
      LOOP AT it_ekpo ASSIGNING <ekpo>.
        FREE : it_fill , it_new.
        CONCATENATE <ekpo>-ebeln <ekpo>-ebelp INTO w_objky.
        CALL FUNCTION 'CV140_SELECT_DRAD_DOCUMENTS'
          EXPORTING
            pf_key       = w_objky
            pf_object    = c_object
          TABLES
            pt_fill_drad = it_fill
            pt_new_drad  = it_new
          EXCEPTIONS
            no_document  = 1.
    * For each DIR , retrieve physical content
        LOOP AT it_fill ASSIGNING <drad>.
          IF <draw> IS ASSIGNED.
            UNASSIGN <draw>.
          ENDIF.
          READ TABLE it_draw ASSIGNING <draw>
             WITH TABLE KEY dokar = <drad>-dokar
                            doknr = <drad>-doknr
                            dokvr = <drad>-dokvr
                            doktl = <drad>-doktl.
          IF NOT <draw> IS ASSIGNED.
            SELECT * FROM draw
               APPENDING CORRESPONDING FIELDS OF TABLE it_draw
               WHERE dokar = <drad>-dokar
                 AND doknr = <drad>-doknr
                 AND dokvr = <drad>-dokvr
                 AND doktl = <drad>-doktl.
            SELECT * FROM drat
               APPENDING CORRESPONDING FIELDS OF TABLE it_drat
               WHERE dokar = <drad>-dokar
                 AND doknr = <drad>-doknr
                 AND dokvr = <drad>-dokvr
                 AND doktl = <drad>-doktl
                 AND langu = sy-langu.
            READ TABLE it_draw ASSIGNING <draw>
               WITH TABLE KEY dokar = <drad>-dokar
                              doknr = <drad>-doknr
                              dokvr = <drad>-dokvr
                              doktl = <drad>-doktl.
          ENDIF.
          CHECK <draw> IS ASSIGNED.
          READ TABLE it_drat ASSIGNING <drat>
                   WITH TABLE KEY dokar = <drad>-dokar
                                  doknr = <drad>-doknr
                                  dokvr = <drad>-dokvr
                                  doktl = <drad>-doktl
                                  langu = sy-langu.
          IF <drat> IS ASSIGNED.
            w_attsub = <drat>-dktxt.
          ELSE.
            CONCATENATE <drad>-dokar <drad>-doknr <drad>-dokvr <drad>-doktl
               INTO w_attsub SEPARATED BY '/'.
          ENDIF.
          PERFORM add_fid_to_attachement USING <draw>
                                               w_attsub
                                      CHANGING my_attachement_list.
          CHECK <drat> IS ASSIGNED.
          UNASSIGN <drat>.
        ENDLOOP.
        LOOP AT it_new ASSIGNING <drad>.
          IF <draw> IS ASSIGNED.
            UNASSIGN <draw>.
          ENDIF.
          READ TABLE it_draw ASSIGNING <draw>
             WITH TABLE KEY dokar = <drad>-dokar
                            doknr = <drad>-doknr
                            dokvr = <drad>-dokvr
                            doktl = <drad>-doktl.
          IF NOT <draw> IS ASSIGNED.
            SELECT * FROM draw
               APPENDING CORRESPONDING FIELDS OF TABLE it_draw
               WHERE dokar = <drad>-dokar
                 AND doknr = <drad>-doknr
                 AND dokvr = <drad>-dokvr
                 AND doktl = <drad>-doktl.
            SELECT * FROM drat
               APPENDING CORRESPONDING FIELDS OF TABLE it_drat
               WHERE dokar = <drad>-dokar
                 AND doknr = <drad>-doknr
                 AND dokvr = <drad>-dokvr
                 AND doktl = <drad>-doktl
                 AND langu = sy-langu.
            READ TABLE it_draw ASSIGNING <draw>
               WITH TABLE KEY dokar = <drad>-dokar
                              doknr = <drad>-doknr
                              dokvr = <drad>-dokvr
                              doktl = <drad>-doktl.
          ENDIF.
          CHECK <draw> IS ASSIGNED.
          READ TABLE it_drat ASSIGNING <drat>
                   WITH TABLE KEY dokar = <drad>-dokar
                                  doknr = <drad>-doknr
                                  dokvr = <drad>-dokvr
                                  doktl = <drad>-doktl
                                  langu = sy-langu.
          IF <drat> IS ASSIGNED.
            w_attsub = <drat>-dktxt.
          ELSE.
            CONCATENATE <drad>-dokar <drad>-doknr <drad>-dokvr <drad>-doktl
               INTO w_attsub SEPARATED BY '/'.
          ENDIF.
          PERFORM add_fid_to_attachement USING <draw>
                                               w_attsub
                                      CHANGING my_attachement_list.
          CHECK <drat> IS ASSIGNED.
          UNASSIGN <drat>.
        ENDLOOP.
      ENDLOOP.
    * Send mail to PO creator
    * Sender
    my_sender-mail = '****' . => Set the sender mail adress
    * Add Recipient
      zcl_send_mail=>add_recipient_to_list(
        EXPORTING
          uname               = sy-uname
        CHANGING
          recipient_list      = my_recipient_list
        EXCEPTIONS
          no_recipient_to_add = 1 ).
    * Mail body
      mail_line = 'PO by mail with Attachment'.
      APPEND mail_line TO it_body.
    * Create send request
      CREATE OBJECT my_mail.
    * Send Mail
      my_mail->send_mail(
          sender                      = my_sender
          mail_subject                = 'E-mail PO'
          mail_body                   = it_body
          recipient_list              = my_recipient_list
          attachement_list            = my_attachement_list ).
    Bellow the code for the routine ADD_FID_TO_ATTACHEMENT
      DATA : w_cout         TYPE dms_checkout_def,
             w_dttrg        TYPE dttrg, "Name of data carrier
             w_docfile      TYPE dms_doc_file,
             w_dappl        TYPE dappl, "Application
             w_tabix        TYPE i ,
             w_tdwa         TYPE tdwa ,
             w_phio         TYPE dms_phio,
             w_frontend TYPE dms_frontend_data.
      DATA : it_drao  TYPE STANDARD TABLE OF drao WITH HEADER LINE,
             it_kpro  TYPE dms_tbl_file .
      CONSTANTS : "c_print_option TYPE apptp VALUE '3', "Print option
                  c_hostname TYPE ntadr VALUE 'DEFAULT', "Hostname
                  c_type TYPE typdt VALUE 'PC', "Type
                  c_system TYPE char4 VALUE 'WN32'. "System
      FIELD-SYMBOLS : <kpro>   TYPE LINE OF dms_tbl_file,
                      <phio>   TYPE LINE OF dms_tbl_phio .
      CLEAR : w_tdwa .
    * Check if for DIR type KPRO is used
      CALL FUNCTION 'CV200_DB_TDWA_SELECT'
        EXPORTING
          pf_dokar  = in_draw-dokar
        IMPORTING
          psx_tdwa  = w_tdwa
        EXCEPTIONS
          not_found = 1.
      w_frontend-frontend_type = c_type. "'PC'.
      w_frontend-hostname      = c_hostname. "'DEFAULT'.
      w_frontend-winsys        = c_system.                      "'WN32'.
      w_frontend-platform      = 0.
      w_cout-comp_get          = abap_true.
      w_cout-kpro_use          = w_tdwa-kpro_use.
      w_cout-batchmode         = abap_true.
      w_cout-content_provide   = 'TBL'.
      CALL FUNCTION 'CV120_KPRO_MASTER_DATA_GET'
        EXPORTING
          pf_dokar  = in_draw-dokar
          pf_doknr  = in_draw-doknr
          pf_dokvr  = in_draw-dokvr
          pf_doktl  = in_draw-doktl
        TABLES
          ptx_data  = it_kpro
        EXCEPTIONS
          not_found = 1
          error     = 2.
      CASE w_tdwa-kpro_use.
        WHEN abap_true.
          CALL FUNCTION 'CV120_KPRO_MASTER_DATA_GET'
            EXPORTING
              pf_dokar  = in_draw-dokar
              pf_doknr  = in_draw-doknr
              pf_dokvr  = in_draw-dokvr
              pf_doktl  = in_draw-doktl
            TABLES
              ptx_data  = it_kpro
            EXCEPTIONS
              not_found = 1
              error     = 2.
          w_frontend-frontend_type = 'KP'.
          LOOP AT it_kpro ASSIGNING <kpro>.
            FREE it_drao.
            LOOP AT <kpro>-tbl_phios ASSIGNING <phio>.
              MOVE-CORRESPONDING <phio> TO w_phio.
              CALL FUNCTION 'CV120_DOC_CHECKOUT_VIEW'
                EXPORTING
                  ps_cout_def = w_cout
                  ps_doc_file = w_docfile
                  ps_draw     = in_draw
                  ps_phio     = w_phio
                  ps_frontend = w_frontend
                TABLES
                  ptx_content = it_drao
                EXCEPTIONS
                  error       = 1.
              PERFORM transform_fid_to_binary TABLES it_drao
                                           USING <kpro>-dappl
                                                 in_attsub
                                          CHANGING attachement_list .
            ENDLOOP.
          ENDLOOP.
        WHEN abap_false.
          DO 2 TIMES.
            CLEAR : w_docfile .
            FREE : it_drao.
            w_tabix = sy-index.
            w_docfile-fileno = w_tabix.
            CASE w_tabix.
              WHEN 1.
                w_dappl = in_draw-dappl.
                w_dttrg = in_draw-dttrg.
              WHEN 2.
                w_dappl = in_draw-dappl1.
                w_dttrg = in_draw-dttrg1.
            ENDCASE.
            w_docfile-dappl = w_dappl.
            w_docfile-dttrg = w_dttrg.
            CALL FUNCTION 'CV120_DOC_CHECKOUT'
              EXPORTING
                ps_cout_def      = w_cout
                ps_draw          = in_draw
                ps_doc_file      = w_docfile
              TABLES
                ptx_drao         = it_drao
              EXCEPTIONS
                error            = 1
                OTHERS           = 2.
            PERFORM transform_fid_to_binary TABLES it_drao
                                       USING w_dappl
                                             in_attsub
                                      CHANGING attachement_list .
          ENDDO.
      ENDCASE.
    Bellow the code for routine TRANSFORM_FID_TO_BINARY
      FIELD-SYMBOLS : <drao>   TYPE drao ,
                      <source> TYPE x ,
                      <dest>   TYPE x,
                      <hexa>   TYPE solix .
      DATA :   w_filelong     TYPE i ,
               w_long         TYPE i,
               w_longdes      TYPE i  .
      DATA :   it_hexa  TYPE solix_tab .
      CHECK it_drao[] IS NOT INITIAL.
    * Transform Physical document into Binary
      LOOP AT it_drao ASSIGNING <drao>.
        IF w_filelong IS INITIAL.
          w_filelong = <drao>-orln.
        ENDIF.
        ASSIGN <drao>-orblk TO <source>.
        DESCRIBE FIELD <source> LENGTH w_long IN BYTE MODE.
        CLEAR w_longdes.
        WHILE w_long GT 0.
          ASSIGN <source>+w_longdes(w_long) TO <source>.
          APPEND INITIAL LINE TO it_hexa ASSIGNING <hexa>.
          ASSIGN <hexa>-line TO <dest>.
          DESCRIBE FIELD <dest> LENGTH w_longdes IN BYTE MODE.
          MOVE <source> TO <dest>.
          w_filelong = w_filelong - w_longdes.
          w_long = w_long - w_longdes.
          CHECK w_filelong LE w_longdes.
          IF w_long NE 0.
            w_long = w_filelong.
          ENDIF.
          CHECK w_long LE 0.
          w_long = 0.
        ENDWHILE.
      ENDLOOP.
    * Add file to list of attachment
      CHECK NOT it_hexa[] IS INITIAL.
      zcl_send_mail=>add_attachement_to_list(
        EXPORTING
          type                       = w_dappl
          subject                    = in_attsub
          content_hexa               = it_hexa
        CHANGING
          attachement_list           = attachement_list
        EXCEPTIONS
          no_content_for_attachement = 1
          no_application_type        = 2 ).
    In my complete solution, an additionnal screen have been define in the header of PO to allow user managing recipient list . If you need so i can give you the code also .
    Let me know.
    Best regards

Maybe you are looking for