Attach text file on email

Hi,
I must attach one table like file ".txt" at an email.
I use the call function "SO_NEW_DOCUMENT_ATT_SEND_API1" and I can send email with attachment the text file.
When I open this file, it is not properly aligned like I see it into table during program process.
If I change the file extension in ".doc", it's attached and is properly aligned.
Do you konw tell me if I must change some function parameter's settings?
Thanks, Davide.

hi try this ..
TABLES: ekko.
PARAMETERS: p_email   TYPE somlreci1-receiver .
TYPES: BEGIN OF t_ekpo,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
  aedat TYPE ekpo-aedat,
  matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
      wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
  ebeln(10) TYPE c,
  ebelp(5)  TYPE c,
  aedat(8)  TYPE c,
  matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                WITH HEADER LINE.
DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                WITH HEADER LINE.
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,
        gd_error    TYPE sy-subrc,
        gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
  Retrieve sample data from table ekpo
  PERFORM data_retrieval.
  Populate table with detaisl to be entered into .xls file
  PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
Populate message body text
  perform populate_email_message_body.
Send file by email as .xls speadsheet
  PERFORM send_file_as_email_attachment
                               tables it_message
                                      it_attach
                                using p_email
                                      'Example .txt documnet attachment'
                                      'txt'
                                      'filename'
                             changing gd_error
                                      gd_reciever.
  Instructs mail send program for SAPCONNECT to send email(rsconn01)
  PERFORM initiate_mail_execute_program.
*&      Form  DATA_RETRIEVAL
      Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
  SELECT ebeln ebelp aedat matnr
   UP TO 10 ROWS
    FROM ekpo
    INTO TABLE it_ekpo.
ENDFORM.                    " DATA_RETRIEVAL
*&      Form  BUILD_XLS_DATA_TABLE
      Build data table for .xls document
FORM build_xls_data_table.
  data: ld_store(50) type c.  "Leading zeros
  CONSTANTS: con_cret(5) TYPE c VALUE '0D',  "OK for non Unicode
             con_tab(5) TYPE c VALUE '09'.   "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
   con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
   con_cret type c value cl_abap_char_utilities=>CR_LF.
  CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.
  CONCATENATE con_cret it_attach  INTO it_attach.
  APPEND  it_attach.
  LOOP AT it_ekpo INTO wa_charekpo.
*Modification to retain leading zeros
  inserts code for excell REPLACE command into ld_store
  =REPLACE("00100",1,5,"00100")
    concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
                             wa_charekpo-ebelp '")' into ld_store .
  concatenate ld_store into .xls file instead of actual value(ebelp)
    CONCATENATE wa_charekpo-ebeln ld_store  wa_charekpo-aedat wa_charekpo-matnr  INTO it_attach SEPARATED BY con_tab.
    CONCATENATE con_cret it_attach  INTO it_attach.
    APPEND  it_attach.
  ENDLOOP.
ENDFORM.                    " BUILD_XLS_DATA_TABLE
*&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
      Send email
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.
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
      Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
  WAIT UP TO 2 SECONDS.
  SUBMIT rsconn01 WITH mode = 'INT'
                WITH output = 'X'
                AND RETURN.
ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
*&      Form  POPULATE_EMAIL_MESSAGE_BODY
       Populate message body text
form populate_email_message_body.
  REFRESH it_message.
  it_message = 'Please find attached a list test ekpo records'.
  APPEND it_message.
endform.                    " POPULATE_EMAIL_MESSAGE_BODY
regards,
venkat.

Similar Messages

  • Trying to attach pdf files to emails I'm sending to myself.  Instead of attaching the file, it copies the text.  I want the file so I can have it on my iPad.  I've been able to do this in the past, but not the last two tries.  What's wrong?  Thanks.

    Trying to attach pdf files to emails I'm sending to myself.  Instead of attaching the file, it copies the text.  I want the file so I can have it on my iPad.  I've been able to do this in the past, but not the last two tries.  What am I doing wrong?  Thanks.

    You aren't doing anything wrong.
    If the PDF is short enough, your iPad Mail app will display the text as part of the mail.
    Actually it is still an attachment.
    Tap and HOLD on the text and you should see options to "Open In..." that will allow you to open the PDF in most PDF readers such as iBooks, GoodReader, etc.

  • How to attached Two file in Email.

    Dear Friends,
    i have an email optoion in my Application .But right now it send mail with out attchment.i want to send meil with attachment .
    i have Two File browser item to attach file ,Please tell me how can i attach these two file with email
    My Code is
    DECLARE
    l_id number;
    to_add varchar2(1000):=:P1_TO;
    from_add varchar2(1000);
    l_body varchar2(4000):=:P1_DESCRIPTION;
    l_sub varchar2(1000):=:P1_SUBJECT;
    BEGIN
       select email_id into from_add from user_master where user_id=:app_user; 
       l_id:=APEX_MAIL.SEND(
            p_to        => to_add, -- change to your email address
            p_from      => from_add,
            p_body      => l_body,
            P_subj      => l_sub);
      COMMIT;
    apex_mail.push_queue(
    P_SMTP_HOSTNAME => '102.111.0.9',
    P_SMTP_PORTNO => 25);
    commit;
    END;How to attached two file in email .
    How can i do this.
    Thanks

    hI,
    thanks to reply me.
    It's REGARDS .
    eg.
    if i am sending any mail then in Bottom of Email Body My Name and Contact No Should be Display.
    Thanks

  • Hi, I am user iPad and I do not know how can attach a file into email e.g. CV.  Thanks

    Hi,
    I am user iPad and I do not know how can attach a file into email e.g. CV. 
    Thanks

    You attach files within the app that creates the file or within the app that the file is saved. For example you email photos from within  the Photos App itself. Typically there will be an action icon within the app - an arrow icon many times - you tap on that to bring other options like Share - then Email.
    Attachments must be mailed within the apps themselves.

  • I can not attach any files to email or Facebook. When I go to "browse" the window comes up and disappears immediately. I updated browser and Adobe Flash. Restarted computer and zapped pram. any ideas? Please help!

    I can not attach any files to email or Facebook. When I go to "browse" the window comes up and disappears immediately. I updated browser and Adobe Flash. Restarted computer and zapped pram. any ideas? Please help!

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box. Don't use the Safari-only Guest login created by Find My Mac.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. The Guest login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    *Note: If FileVault is enabled under Mac OS X 10.7 or later, or if a firmware password is set, you can’t boot in safe mode.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • Downloading attached zip file from emails using safari

    How to download, and where will be the downloaded attached zip file in email be stored using safari? How to open and save the zip file attached to the email? Do you need an app to open and store the zip file?

    The app GoodReader (I don't know if there are any free apps that can also do it) can be used to zip and unzip email attachments
    press and hold the zip file in your email - after a couple of seconds you should get a popup, with one option being 'Open in GoodReader' which you should select
    GoodReader should then open with the zip file listed under My Documents
    select Manage Files on the right-hand side of GoodReader, select the zip file, and touch the Unzip button that appears on the right
    You should also be able to download zip files directly into GoodReader by typing the URL in its Wed Downloads sectio.

  • Issue the send attach Pdf file in Email. (Urgent).

    Hello folks, i have issue with attach pdf in e-mail using two lib´s: activation.jar and mail.jar. Currently using a platform SOA and am creating the serviceType, then a file don´t is local and yes by message, so far so good.
    Already tried in several forums, but without success.
    When send the message (pdf file), the program receive a type ContentType (application/octet-stream) and cause the MessageException, below:
    MessageException - in Container:
    Message: [B@79ffb7f7  /// the service received the pdf file
    [09/03/02 12:22:45] ID=dev_ESBTest (info) application/octet-stream *///ContentType of message*
    javax.mail.SendFailedException: Sending failed; *///Exception*
    nested exception is:
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
    **javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream**
    at javax.mail.Transport.send0(Transport.java:219)
    at javax.mail.Transport.send(Transport.java:81)
    javax.mail.MessagingException: IOException while sending message;
    nested exception is:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream
    at com.sun.mail.smtp.SMTPTransport.sendMessage (SMTPTransport.java:353)
    at javax.mail.Transport.send0 (Transport.java:164)
    at javax.mail.Transport.send(Transport.java:81)
    With this, it send the e-mail without attach......above my source simple source code.
    ServiceType Code:
         protected void SendEmail(XQPart prt, String host, String from, String to) {
              // create some properties and get the default Session
              Properties props = System.getProperties();
              props.put("mail.smtp.host";, host);
              Session session = Session.getInstance(props, null);
              try {
                   // create a message
                   MimeMessage msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(from));
                   InternetAddress[] address = { new InternetAddress(to) };
                   msg.setRecipients(Message.RecipientType.TO, address);
                   msg.setSubject("Test Subject.");
                   MimeBodyPart bp1 = new MimeBodyPart();
                   bp1.setText("Test Text.");
                   MimeBodyPart bp2 = new MimeBodyPart();
                   m_xqLog.logInformation(prt.getContentType());
                   bp2.setContent(prt.getContent(), prt.getContentType());
                   bp2.setFileName("teste.pdf";);
                   Multipart mp = new MimeMultipart();
                   mp.addBodyPart(bp1);
                   mp.addBodyPart(bp2);
                   msg.setContent(mp);
                   msg.setSentDate(new Date());
                   Transport.send(msg);
                   System.out.println("Email sent successfully!");
              } catch (MessagingException mex) {
                   mex.printStackTrace();
                   Exception ex = null;
                   if ((ex = mex.getNextException()) != null) {
                        ex.printStackTrace();
         }Anybody would can help me, please....
    Thanks ....
    Paulo Sampei.

    Hello Folks, me again. Then the solution about this question above, below:
    Solution:
    Code 1: Call 2 method passing requirement parameter:
    Obs: Always ContentType = application/octet-stream
    ByteArrayInputStream attachStream = new ByteArrayInputStream((byte[]) prt.getContent());
    //call constructor class:InputStreamDataSource
    InputStreamDataSource isds = new InputStreamDataSource("Testepdf.pdf", prt.getContentType(),attachStream);
    //call method sendMail(InputStreamDataSource,host,from,to)
    sendMail(isds, s_Host, s_SendFrom, s_SendTo);Code 2: Class InputStreamDataSource
         // statement DataSource
         private class InputStreamDataSource implements DataSource {
              private String name;
              private String contentType;
              private ByteArrayOutputStream baos;
              InputStreamDataSource(String name, String contentType,
                        InputStream inputStream) throws IOException {
                   int read;               
                   this.name = name;
                   this.contentType = contentType;
                   baos = new ByteArrayOutputStream();
                   byte[] buff = new byte[256];               
                   while ((read = inputStream.read(buff)) != -1) {
                        baos.write(buff, 0, read);
              public String getContentType() {
                   // TODO Auto-generated method stub
                   return contentType;
              public InputStream getInputStream() throws IOException {
                   // TODO Auto-generated method stub
                   return new ByteArrayInputStream(baos.toByteArray());
              public String getName() {
                   // TODO Auto-generated method stub
                   return name;
              public OutputStream getOutputStream() throws IOException {
                   // TODO Auto-generated method stub
                   throw new IOException("Cannot write to this read-only resource");
         }Code 3: mehod sendMail(InputStreamDataSource, host, from, to)
         protected void sendMail(InputStreamDataSource attach, String host,
                   String from, String to) {
              // create some properties and get the default Session
              Properties props = System.getProperties();
              props.put("mail.smtp.host", host);
              Session session = Session.getInstance(props, null);
              try {
                   // create a message
                   MimeMessage msg = new MimeMessage(session);
                   msg.setFrom(new InternetAddress(from));
                   InternetAddress[] address = { new InternetAddress(to) };
                   msg.setRecipients(Message.RecipientType.TO, address);
                   msg.setSubject("Assunto teste.");
                   // create and fill the first message part
                   MimeBodyPart bp1 = new MimeBodyPart();
                   bp1.setText("Texto teste.");
                   // create the second message part
                   m_xqLog.logInformation("[ContentType]:[attach] "
                             + attach.getContentType());
                   // attach the file to the message
                   MimeBodyPart bp2 = new MimeBodyPart();
                   bp2.setDataHandler(new DataHandler(attach));
                   bp2.setFileName(attach.getName());
                   // create the Multipart and add its parts to it
                   Multipart mp = new MimeMultipart();
                   mp.addBodyPart(bp1);
                   mp.addBodyPart(bp2);
                   // add the Multipart to the message
                   msg.setContent(mp);
                   // set the Date: header
                   msg.setSentDate(new Date());
                   // send the message
                   Transport.send(msg);
                   System.out.println("Email sent successfully!");
              } catch (MessagingException mex) {
                   mex.printStackTrace();
                   Exception ex = null;
                   if ((ex = mex.getNextException()) != null) {
                        ex.printStackTrace();
         }Thank you very much, forum and bshannon at your tips.
    Cheers,
    Paulo Sampei.

  • Attach a file to Email

    Hi, can anyone please guide me on how to attach a file in my phone to an email reply. (I can draft a new mail with attached file by using iFile only)

    Hello DrAnujGupta and All,
    The same here...
    I use my iPhone/iPad for both personal and professional matters. We all use the Mac email client for long time and clearly being able to attach a file while composing or replying and email is a needed feature.
    Below the two situations where I really miss of this feature:
    a) I'm composing an email - already typed large amount of text - and realized that by attach a certain file the information would be more complete.
    My workaround: Copy the list of - To: - destination email and past it in some text file, copy the message body text  and past it in some text file, go the proper application containing the file a want to sent by email, use the application "share" or "sent by email" button - assuming that the application has such feature, copy back the email list and the body text.
    b) I have received an email from from someone that is after a report. I need to reply with an attachment, keeping the same email conversation thread. This example, the current workaround can be a bit more cumbersome if the sender email address is not part of my address book.
    address is not in my address book.
    My workaround: I reply to the person - or list of people - informing that I will sent another email with the required document.
    Please note that those workarounds are not meant to provide solution to this problem, but to expose how hard is to live without this feature.
    I believe that this may be related with the fact that iOS applications are "sandboxed", jailed aiming a more secure application runtime environment - I'm not an expert, just guessing here... The email application seems to have a reasonable ability to know which application can open a received attachment file. This demonstrates that there is a way - or there could be a way - to allow the applications to exchange files in a secure way. If this is truth, the other applications should also be able to share files with email application.
    ANx

  • Attaching notepad file for email

    Hi experts,
    I have some data in internal table which i want to send as a notepad file as attachment. I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1, however i am using the doc_type as 'TXT' and my ouput file is not properly formatted even though i am using the delimiters like HORIZONTAL_TAB.
    How this can be solved?
    Thanks.
    Warm regards,
    Harshad.

    Hi Harshad ,
    for proper formatting you try to run this code.....
    *& Report  ZPAWAND_BACKGROUND_SENDMAIL3
    REPORT  ZPAWAND_BACKGROUND_SENDMAIL3.
    TABLES: ekko.
    PARAMETERS: p_email TYPE somlreci1-receiver DEFAULT
    'enter the email id'.
    TYPES: BEGIN OF t_ekpo,
            ebeln TYPE ekpo-ebeln,
            ebelp TYPE ekpo-ebelp,
            aedat TYPE ekpo-aedat,
            matnr TYPE ekpo-matnr,
          END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
    wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
             ebeln(10) TYPE c,
             ebelp(5) TYPE c,
             aedat(8) TYPE c,
             matnr(18) TYPE c,
           END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 WITH
    HEADER LINE.
    DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0 WITH
    HEADER LINE.
    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,
          gd_error TYPE sy-subrc,
          gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
    Retrieve sample data from table ekpo
      PERFORM data_retrieval.
    Populate table with detaisl to be entered into .txt file
      PERFORM read_data_txt_old.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .txt speadsheet
    PERFORM send_file_as_email_attachment TABLES it_message it_attach USING
    p_email 'Example .txt documnet attachment' 'txt' 'filename' ' ' ' ' ' '
        CHANGING gd_error gd_reciever.
    Instructs mail send program for sapconnect to send email(rsconn01)
      perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
         UP TO 10 ROWS FROM ekpo INTO TABLE it_ekpo.
    ENDFORM. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    Build data table for .xls document
    *FORM build_xls_data_table.
    *&      Form  READ_DATA_TXT_OLD
          text
    form read_data_txt_old.
    *CONSTANTS: con_cret TYPE c VALUE '0D', "OK for non Unicode
              con_tab TYPE c VALUE '09'. "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    CONSTANTS: con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
               con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
               concatenate  it_attach CL_ABAP_CHAR_UTILITIES=>NEWLINE into
    it_attach.
    CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY
    con_tab.
    CONCATENATE con_cret it_attach INTO it_attach.
    APPEND it_attach.
    LOOP AT it_ekpo INTO wa_charekpo.
      CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp wa_charekpo-aedat
        wa_charekpo-matnr INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach INTO it_attach.
      APPEND it_attach.
    ENDLOOP.
    ENDFORM. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    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.
    **************For Proper Formatting*********************
      ld_mtitle =
      'Material to Material transfer report .txt document attachment'.
      ld_format              = 'RAW'.        "'TXT'.
    ld_attdescription      = 'OUTPUT of Report'.
      ld_attfilename         = 'output_file'.
      ld_sender_address      = ' '.
      ld_sender_address_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.                    "READ_DATA_TXT_OLD
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT' WITH output = 'X' AND RETURN.
    ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    Populate message body text
    FORM populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    ENDFORM. " POPULATE_EMAIL_MESSAGE_BODY
    Regards,
    Pawan

  • Attaching text file using SO_NEW_DOCUMENT_ATT_SEND_API1

    hello guys, i'm a newbie here.
    I'm having trouble attaching an existing text file using function 'SO_NEW_DOCUMENT_ATT_SEND_API1'. It seems i can't find the right combination of parameters that are being passed to this function.
    first, i'm using WS_UPLOAD to upload the text file to an internal table then i'm creating all the neccessary internal tables that will be use by this function..
    By the way, i'm trying to send mail w/ attachments to external mail and SAPids. Below is my code.
    REPORT ZHR_TESTEMAIL .
    TABLES: USR02, PA0105, SOSU, SOUC, RLGRAP, IBIPPARMS, DYNPREAD, RSCSEL.
    DATA: FOLD_YR(2) TYPE C,
          FOLD_TYPE(3) TYPE C,
          G_HEADER LIKE SOOD2,
          G_FOLMAM LIKE SOFM2,
          METHOD1 LIKE SY-UCOMM,
          G_DOCUMENT LIKE SOOD4,
          G_USER LIKE SOUDNAMEI1,
          FOLD_NUMBER(12) TYPE C,
          G_NEW_PARENT LIKE SOODK,
          G_OWNER LIKE SOUD-USRNAM,
          G_REF_DOCUMENT LIKE SOOD4,
          G_USER_DATA LIKE SOUDATAI1,
          G_AUTHORITY LIKE SOFA-USRACC,
          G_OBJCNT LIKE SOLI OCCURS 0 WITH HEADER LINE,
          G_OBJHEAD LIKE SOLI OCCURS 0 WITH HEADER LINE,
          G_OBJPARA LIKE SELC OCCURS 0 WITH HEADER LINE,
          G_OBJPARB LIKE SOOP1 OCCURS 0 WITH HEADER LINE,
          G_RECIPIENTS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,
          G_REFERENCES LIKE SOXRL OCCURS 0 WITH HEADER LINE,
          G_ATTACHMENTS LIKE SOOD5 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF G_FILES OCCURS 10 ,
          TEXT(4096) TYPE C,
          END OF G_FILES.
    DATA: BEGIN OF IT_WS_FILE OCCURS 0,
          WS_FILE LIKE RLGRAP-FILENAME,
          END OF IT_WS_FILE.
    DATA: BEGIN OF IT_SAPID OCCURS 0,
          SAPID LIKE USR02-BNAME,
          END OF IT_SAPID.
    DATA: BEGIN OF IT_EMAIL OCCURS 0,
          EMAILADD LIKE PA0105-USRID_LONG,
          END OF IT_EMAIL.
    DATA: BEGIN OF IT_TSP01 OCCURS 0.
            INCLUDE STRUCTURE TSP01.
    DATA: END OF IT_TSP01.
    DATA: BEGIN OF TAB2 OCCURS 50,
          TEXT(200) TYPE C,
          END OF TAB2.
    DATA: V_DOCDATA TYPE SODOCCHGI1,
          V_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
          V_OBJHEAD LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJTXT  LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJBIN  LIKE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          V_OBJHEX  LIKE SOLIX      OCCURS 0 WITH HEADER LINE,
          IT_RECVRS TYPE SOMLRECI1  OCCURS 0 WITH HEADER LINE,
          IT_CONTNT TYPE SOLISTI1   OCCURS 0 WITH HEADER LINE,
          IT_BODY   LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE,
          V_TLIN    TYPE I,
          V_LINE    TYPE I.
    DATA: BEGIN OF IT_TEXTLINE OCCURS 500,
          TEXTLINE(5000),
          END OF IT_TEXTLINE.
    DATA: FYL LIKE RLGRAP-FILENAME,
          GV_SUBNO LIKE SOSU-SUBNO,
          GV_EMAIL LIKE PA0105-USRID_LONG,
          GV_NEXTDAY LIKE SY-DATUM,
          YEAR(4) TYPE C,
          RECFLAG TYPE C.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM WITH FRAME TITLE TEXT-001.
    PARAMETERS: SUBJ(254) TYPE C OBLIGATORY,            "Subject
                DESC(254) TYPE C.                       "Message
    SELECT-OPTIONS: SAPID FOR USR02-BNAME NO INTERVALS. "Recipient's SAP ID
    SELECT-OPTIONS: EMAILADD FOR PA0105-USRID_LONG NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK PARAM.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS: WS_FILE FOR DYNPREAD-FIELDNAME NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK PARAM2.
    SELECTION-SCREEN BEGIN OF BLOCK PARAM3 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT1 RADIOBUTTON GROUP A USER-COMMAND BUT. "Local PC
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT1.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT2 RADIOBUTTON GROUP A.                  "Server
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: RBUT3 RADIOBUTTON GROUP A.                  "Spool
    SELECTION-SCREEN COMMENT 5(20) FOR FIELD RBUT3.
    PARAMETERS: SPOOLNUM LIKE RSPOTYPE-RQNUMBER.            "Spool Number
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK PARAM3.
    SELECTION-SCREEN BEGIN OF BLOCK PROC WITH FRAME TITLE TEXT-004.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETER: BPROC AS CHECKBOX USER-COMMAND BCK. "Background Processing
    SELECTION-SCREEN COMMENT 5(50) FOR FIELD BPROC.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK PROC.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR WS_FILE-LOW.
      DATA: WS_FILE_TEMP TYPE IBIPPARMS-PATH.
      CLEAR: WS_FILE_TEMP.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME  = SY-REPID
                DYNPRO_NUMBER = SY-DYNNR
                FIELD_NAME    = 'WS_FILE'
           IMPORTING
                FILE_NAME     = WS_FILE_TEMP.
      WS_FILE-LOW = WS_FILE_TEMP.
    AT SELECTION-SCREEN.
      SELECT SAPNAM FROM SOUC
          INTO TABLE IT_SAPID
          WHERE SAPNAM IN SAPID
            AND DELETED = ''.
      GV_NEXTDAY = SY-DATUM + 1.
      LOOP AT EMAILADD.
        IT_EMAIL-EMAILADD = EMAILADD-LOW.
        APPEND IT_EMAIL.
        CLEAR: IT_EMAIL.
      ENDLOOP.
      IF NOT BPROC IS INITIAL.
        CLEAR: RBUT1, RBUT3.
        RBUT2 = 'X'.
      ELSE.
        CLEAR: RBUT2.
      ENDIF.
      IF NOT RBUT3 IS INITIAL.
        REFRESH: WS_FILE.
      ENDIF.
      IF SAPID IS INITIAL AND EMAILADD IS INITIAL.
        MESSAGE E000(ZZ) WITH TEXT-201.
      ELSEIF NOT SAPID IS INITIAL AND EMAILADD IS INITIAL.
        CLEAR IT_SAPID.
        READ TABLE IT_SAPID.
        SELECT SINGLE SUBNO FROM SOSU
          INTO GV_SUBNO
          WHERE USRNO IN ( SELECT USRNO FROM SOUC
                             WHERE SAPNAM = IT_SAPID-SAPID ).
        IF SY-SUBRC NE 0.
          MESSAGE E000(ZZ) WITH TEXT-202.
        ENDIF.
        CLEAR: IT_SAPID.
      ELSEIF NOT SAPID IS INITIAL AND NOT EMAILADD IS INITIAL.
        CLEAR: IT_SAPID, IT_EMAIL.
        READ TABLE IT_SAPID.
        READ TABLE IT_EMAIL.
        SELECT SINGLE SUBNO FROM SOSU
          INTO GV_SUBNO
          WHERE USRNO IN ( SELECT USRNO FROM SOUC
                             WHERE SAPNAM = IT_SAPID-SAPID ).
        IF SY-SUBRC NE 0.
          SUBMIT RSSOADM0 WITH USRNAM EQ IT_SAPID-SAPID
                          WITH NEW_SUBS EQ IT_EMAIL-EMAILADD
                          WITH SUB_ESC EQ 'U'
                          WITH EDAT EQ SY-DATUM
                          WITH BDAT EQ SY-DATUM
                         WITH BDAT EQ GV_NEXTDAY
                         WITH EDAT EQ '99991231'
                          WITH BTIM EQ SY-UZEIT
                          WITH ETIM EQ '240000'
                          WITH FORW_ALL EQ 'X'
                          WITH PSTHR2 EQ ''
                          AND RETURN.
        ENDIF.
        CLEAR: IT_SAPID.
      ELSEIF NOT EMAILADD IS INITIAL AND SAPID IS INITIAL.
        RECFLAG = 'X'.
      ENDIF.
    START-OF-SELECTION.
        PERFORM B_SENDMAIL.
    FORM B_SENDMAIL.
      YEAR = SY-DATUM+0(4).
      LOOP AT WS_FILE.
        CLEAR: FYL.
        FYL = WS_FILE-LOW.
        REFRESH: TAB2.
        CALL FUNCTION 'WS_UPLOAD'
             EXPORTING
                  FILENAME = FYL
                  FILETYPE = 'BIN'
             TABLES
                  DATA_TAB = TAB2.
        IT_TEXTLINE[] = TAB2[].
    DOCUMENT_DATA (SUBJECT OF MAIL)
        V_DOCDATA-OBJ_NAME   = DESC.
        V_DOCDATA-OBJ_DESCR  = SUBJ.
        V_DOCDATA-OBJ_LANGU  = SY-LANGU.
        V_DOCDATA-SENSITIVTY = 'C'.
        V_DOCDATA-OBJ_PRIO   = '1'.
    BODY OF MAIL
        IT_BODY-LINE = 'Collection Report'.
        APPEND IT_BODY.
    CONTENTS_TXT (Attachments)
        IT_CONTNT[] = IT_TEXTLINE[].
        DESCRIBE TABLE IT_CONTNT LINES V_LINE.
        READ TABLE IT_CONTNT INDEX V_LINE.
    PACKING_LIST
        V_OBJPACK-DOC_SIZE = ( V_LINE - 1 ) * 255 + STRLEN( IT_CONTNT ).
        V_OBJPACK-TRANSF_BIN = 'X'.
        V_OBJPACK-HEAD_START = 1.
        V_OBJPACK-HEAD_NUM   = 0.
        V_OBJPACK-BODY_START = 1.
        V_OBJPACK-BODY_NUM   = V_LINE.
        V_OBJPACK-DOC_TYPE   = 'TXT'.
        V_OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
        V_OBJPACK-OBJ_DESCR  = 'Attached Document'.
        APPEND V_OBJPACK.
        CLEAR  V_OBJPACK.
    RECEIVERS of mail
        IF RECFLAG IS INITIAL.
          LOOP AT IT_SAPID.
            IT_RECVRS-RECEIVER   = IT_SAPID-SAPID.
            IT_RECVRS-REC_TYPE   = 'B'.
            IT_RECVRS-COM_TYPE   = ''.
            IT_RECVRS-EXPRESS    = 'X'.
            IT_RECVRS-NO_FORWARD = ''.
            IT_RECVRS-NO_PRINT   = ''.
            APPEND IT_RECVRS.
            CLEAR IT_RECVRS.
          ENDLOOP.
        ELSE.
          LOOP AT EMAILADD.
            IT_RECVRS-RECEIVER   = EMAILADD-LOW.
            IT_RECVRS-REC_TYPE   = 'U'.
            IT_RECVRS-COM_TYPE   = 'INT'.
            IT_RECVRS-EXPRESS    = 'X'.
            APPEND IT_RECVRS.
            CLEAR IT_RECVRS.
          ENDLOOP.
        ENDIF.
    OBJECT_HEADER (Filename)
        CONCATENATE 'Collection Report' '_'
                     SY-DATUM+4(4) YEAR '.TXT'
                     INTO V_OBJHEAD-LINE.
       V_OBJHEAD-LINE = FYL+16(25).
        APPEND V_OBJHEAD.
        CLEAR V_OBJHEAD.
    Function Module For Sending Mail with Attachment
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
             EXPORTING
                  DOCUMENT_DATA              = V_DOCDATA
             TABLES
                  PACKING_LIST               = V_OBJPACK
                  OBJECT_HEADER              = V_OBJHEAD
                  CONTENTS_HEX               = IT_CONTNT
                  CONTENTS_TXT               = IT_BODY
                  RECEIVERS                  = IT_RECVRS
             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.
          MESSAGE S000(ZZ) WITH TEXT-005.
        ELSE.
          MESSAGE S000(ZZ) WITH TEXT-006.
        ENDIF.
      ENDLOOP.
    end of my code *
    please help me guys... when i run this program,    DOCUMENT_NOT_SENT is what i always get.. 
    waiting for ur reply... thank you vey much and godbless.

    Hi,
    Try this sample code.
    FORM SEND_TO_EMAIL USING zFName.
      DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
      DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
      DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
      DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
      DATA: DOC_CHNG LIKE SODOCCHGI1.
      DATA: TAB_LINES LIKE SY-TABIX.
      DATA: ctmp(50) TYPE C.
    Creation of the document to be sent
      DOC_CHNG-OBJ_NAME = 'JOURNAL'.
      CONCATENATE 'SAP Payroll Journal file Period' pybegda INTO ctmp
                  SEPARATED BY SPACE.
      DOC_CHNG-OBJ_DESCR = cTmp.
      OBJTXT = 'SAP Payroll Journal'.
      APPEND OBJTXT.
      CONCATENATE 'For Period' pybegda INTO ctmp
                  SEPARATED BY SPACE.
      OBJTXT = ctmp.
      APPEND OBJTXT.
      CONCATENATE 'Attached File :' zFname INTO ctmp
                  SEPARATED BY SPACE.
      OBJTXT = ctmp.
      APPEND OBJTXT.
      OBJTXT = 'Please find the attachment.'.
      APPEND OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ TABLE OBJTXT INDEX TAB_LINES.
      DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creation of the entry for the compressed document
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
    Creation of the document attachment
      <b>LOOP AT xMail.
        CONDENSE xMail-aline.
        OBJBIN = xMail-aline.
        APPEND OBJBIN.
        CLEAR OBJBIN.
      ENDLOOP.</b>
      DESCRIBE TABLE OBJBIN LINES TAB_LINES.
      OBJHEAD = zFname. APPEND OBJHEAD.
    Creation of the entry for the compressed attachment
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      OBJPACK-OBJ_NAME = 'DATA'.
      OBJPACK-OBJ_DESCR = 'SAP Payroll File'.
      OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND OBJPACK.
    Completing the recipient list
      LOOP AT PENERIMA.
        CONDENSE PENERIMA-PNRM.
        RECLIST-RECEIVER = PENERIMA-PNRM.
        RECLIST-REC_TYPE = 'U'.
        APPEND RECLIST.
      ENDLOOP.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = DOC_CHNG
                PUT_IN_OUTBOX              = ' '
           TABLES
                PACKING_LIST               = OBJPACK
                OBJECT_HEADER              = OBJHEAD
                CONTENTS_BIN               = OBJBIN
                CONTENTS_TXT               = OBJTXT
                RECEIVERS                  = RECLIST
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                OPERATION_NO_AUTHORIZATION = 4
                OTHERS                     = 99.
      CASE SY-SUBRC.
        WHEN 0.
          WRITE: / 'Result of the send process:'.
          LOOP AT RECLIST.
            WRITE: / RECLIST-RECEIVER(48), ':'.
            IF RECLIST-RETRN_CODE = 0.
              WRITE / 'The document was sent'.
            ELSE.
              WRITE / 'The document could not be sent'.
            ENDIF.
          ENDLOOP.
        WHEN 1.
          WRITE: / 'Too many receiver'.
        WHEN 2.
          WRITE: / 'Document could not be sent to any recipient'.
        WHEN 4.
          WRITE: / 'No send authorization'.
        WHEN OTHERS.
          WRITE: / 'Error occurred while sending'.
      ENDCASE.
    ENDFORM.

  • Can no longer attach pdf files into email.

    I recently purchased a new computer with Windows 8.1 as the OS.  Seems that I am no longer able to attach PDF files into any email.  Any clues as to what has gone wrong?

    Thanks for the help.  Seems I had a failed Windows update several weeks past I had forgottent about.  Had to do a restore to the prior date to get back to the right configuration.  Did an online session with Mircosoft, reinitiated the update, and it seems as if the issue is resolved.  We were able to re-test attaching and send pdf files. Seems there is still some slight issue with IE, but you appear to be on the right track about focusing on Web Outlook if the problem continues to surface.  Thanks again.

  • Attaching Text file and sending mail

    Hi all,
              I am trying to attach a text file (ASCII file) and send using mail.
              I am not able to get proper data in attachement.Can anyone suggest me which type should i use
              to get the data in proper format.
              i was using RAW file. I found we dont have specific Text format.
             Its possible for XLS format, i need only text file to be attached.
    Thanks,
    Rajesh
    Edited by: rajesh pattnaik on Apr 16, 2009 3:03 PM

    Hi,
    After bringing your final alv data in the final internal table,
    go through this link , i also had an same requirement to send data after converting to excel file and
    send it as an attachment to mail id outside Sap,
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/to%252bsend%252b2%252bint%252btables%252bdata%252bas%252btwo%252battachments%252bto%252bmail%252bid%252boutside%252bsap%252bsystem
    I did this object and it was working fine using that function module.
    Hope it helps
    Regrds
    Mansi

  • How do I attach photo files to email message in iPhoto '11?

    Apple says, "If you want recipients to be able to use the photos you send, rather than simply view them, you can attach the photo files to your email message. (BUT HOW?) Recipients can then download the photos from the email message and print them, use them in their own projects, and so on."
    How do I attach these files when sending an email of photos using iPhoto? (I don't want to use AppleMail, I know how to do it in AppleMail) When I click to Share my photos via email in iPhoto, I do not see any option rbutton to add files to make the photos easily downloadable for the recipient.  Anyone know how to do this?  Thanks!

    Not sure why you can't deselect the option, but I would guess that yes, the files are being attached.
    Who are you sending to? iPhoto sends HTML emails and not every application on Windows or Mac knows how to deal with them, for instance, nor every user.
    Regards
    TD

  • I can not attach jpeg files to Email. I am running XP and use Yahoo mail

    I can not attach a picture / JPEG file to an email. I use yahoo email and have XP on the computer. I did not have this problem till I downloaded Firefox. Also since downloading firefox I can not get Internet explorer to connect to the internet.
    == This happened ==
    Every time Firefox opened
    == When I loaded Firefox

    Ernie
    thanks for the reply Here are the answers to your questions.
    yes each account has it's own drafts folder. and I can save the file into the drafts folder after follow the steps you outlined in your answer. I did repair permission but nothing has changed .
    one thing i discovered is that I can attach files to the mail if i reply to it. only when i create a new mail in one of those accounts can i not attach any files.
    Seeing on the side bar that you are a top user I have another question you might be able to answer
    my apple help is not working, when i go to finder and go to mac help the page is blank and if i search it just searches and nothing happens

  • I get a spinning pinwheel when trying to attach a file to email - running Mavericks.  iMac just hangs, have to power off

    Suddenly, without having made any significant changes to my iMac running Mavericks, I cannot attach a file to an email. I get a spinning wheel, I can't even force quit, the machine just locks up.  Happens with different mail clients and different browsers.

    Hello E1777,
    You can try this link to download iTunes from the Apple website. It should resolve the issue for you.
    iTunes 11.0.4
    http://support.apple.com/kb/dl1614
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

Maybe you are looking for

  • Firefox carshes at startup no settings have changed. Latest version of FF. I just rebooted the computer from windows updates.

    After reboot and installing windows updates etc. FF crashes all the sudden. No idea why. I have deleted all profiles completely, unintsalled ran ccleaner and reinstalled. nothing. Any ideas? I don't think windows updates effect FF. FF will not even o

  • Chrome, Mountain Lion and Full Screen Interactive Mode

    I'm running into an issue when entering Full Screen (Interactive) Mode-- long story short, the Message and "Allow" button are over-magnified and don't appear on the screen for me to click, thereby making it impossible to use other keystrokes (and see

  • Error in Transfer Process (Urgent )

    Hi, I am working with a classic scenario and the problem is that after the Shopping cart is approved,the follow-on document is not getting created. In the Follow on doc tab I get the status as "Shopping Cart Approved" When I check the SC in t-code BB

  • Import and Export Function

    Hi all, My application does not work properly after I do the export/import application function. When I import the application, two things fail - the page authorization scheme and the breadcrumbs. What can i do to avoid this problem ? jeff.

  • Microphone Probl

    Hello, I am currently experiencing a very odd problem with my microphone. I was using a Realtek 97 onboard audio for a couple of months and my microphone reception was crystal clear and perfect when using Team Speak, Ventrillo, Skype or any other pro