To send TXT file as an attachment  through Email

Hi Experts,
I am working on requirement where i have to send a txt file as an attachment.
Could any one suggest me a solution.
Thanks and Regards,
Jeswanth Kadali

Hi,
Use the function module SO_NEW_DOCUMENT_ATT_SEND_API1.
We find it convenient to use a custom function module as a wrapper for that.
Here's the code.
FUNCTION Z_EMAILS_ATTACH.
""Local interface:
*"  IMPORTING
*"     VALUE(EMAIL_SUBJECT) LIKE  SODOCCHGI1-OBJ_DESCR
*"     VALUE(ATTACHMENT_SUBJECT) LIKE  SOPCKLSTI1-OBJ_DESCR OPTIONAL
*"     VALUE(ATTACHMENT_DOC_TYPE) TYPE  SO_OBJ_TP OPTIONAL
*"     REFERENCE(ATTACHMENT_HEADER) LIKE  SOLISTI1 STRUCTURE  SOLISTI1
*"  TABLES
*"      EMAIL_BODY STRUCTURE  SOLISTI1
*"      EMAIL_ATTACHMENT STRUCTURE  SOLISTI1 OPTIONAL
*"      RECEIVERS STRUCTURE  SOMLRECI1
*"  EXCEPTIONS
*"      UNKNOWN_COMMUNICATION_TYPE
*"      ERROR_SENDING_MAIL
*"      EMPTY_ATTACHMENT
*"      NO_ATTACHMENT_SUBJECT
*"      USER_HAS_NO_EMAIL_ADDRESS
*"      NO_RECEIVERS
NOTE
Single-testing when the tables passed to the function have reference
structure SOLISTI1 meets with a problem.
Entering non-blank rows into these tables is impossible, it seems.
This is believed to be because the single testing fails to cope with
the width of SOLISTI1-LINE [255 char].
For single testing, use CVDTLINE as the reference structure - it's
only 132 char.  Then remember to change it back to SOLISTI1...
Based on Z_EMAIL_ATTACH which sends just one mail.
08.06.2007  JNM
DATA: document LIKE sodocchgi1.
DATA: packlist LIKE sopcklsti1     OCCURS 0 WITH HEADER LINE.
DATA: contents LIKE solisti1       OCCURS 0 WITH HEADER LINE.
DATA: header   LIKE solisti1       OCCURS 0 WITH HEADER LINE.
DATA: RECVLIST LIKE SOMLRECI1      OCCURS 0 WITH HEADER LINE.
DATA: NEXT_ROW LIKE SY-TABIX.
DATA: lines    LIKE sy-tabix.
DATA: LAST_LINE_LENGTH TYPE I.
DATA: d_doc_size LIKE packlist-doc_size.
data: email_address type ad_smtpadr.
A user without an email address cannot email.
CALL FUNCTION 'Z_USER_EMAIL_ADDRESS'
  EXPORTING
    USER_NAME              = SY-UNAME
  IMPORTING
    EMAIL_ADDRESS          = email_address
  EXCEPTIONS
    UNKNOWN_USER           = 1
    NO_ADDRESS_KEY         = 2
    NO_ADDRESS_DATA        = 3
    NO_EMAIL_ADDRESS       = 4
    OTHERS                 = 5.
IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4
          raising USER_HAS_NO_EMAIL_ADDRESS.
  ENDIF.
Receivers?
describe table receivers lines lines.
if lines eq 0.
  raise no_receivers.
  endif.
initialization
CLEAR: CONTENTS, DOCUMENT, HEADER, PACKLIST, RECVLIST.
REFRESH: CONTENTS, HEADER, PACKLIST, RECVLIST.
attachment?
DESCRIBE TABLE EMAIL_ATTACHMENT LINES LINES.
IF LINES EQ 0 AND ATTACHMENT_SUBJECT CN SPACE.
  RAISE EMPTY_ATTACHMENT.
  ENDIF.
IF LINES NE 0 AND ATTACHMENT_SUBJECT CO SPACE.
  RAISE NO_ATTACHMENT_SUBJECT.
  ENDIF.
email body
concatenate 'SAP client:'
  sy-host sy-sysid sy-mandt
  into contents separated by space.
append contents.
clear contents.
append contents.
APPEND LINES OF EMAIL_BODY TO CONTENTS.
header - row for body
HEADER = 'BODY HEADER'.
APPEND HEADER.
packing list - row for body
PACKLIST-TRANSF_BIN = SPACE.
PACKLIST-HEAD_START = 1.
PACKLIST-HEAD_NUM = 1.
PACKLIST-BODY_START = 1.
DESCRIBE TABLE CONTENTS LINES PACKLIST-BODY_NUM.
NEXT_ROW = 1 + PACKLIST-BODY_NUM.
*packlist-doc_type = 'EXT'.
PACKLIST-DOC_TYPE = 'RAW'.
APPEND PACKLIST.
IF ATTACHMENT_SUBJECT CN SPACE. " if there's an attachment
attachment into contents
  APPEND LINES OF EMAIL_ATTACHMENT TO CONTENTS.
  DESCRIBE TABLE EMAIL_ATTACHMENT LINES LINES.
  READ TABLE EMAIL_ATTACHMENT INDEX LINES.
  LAST_LINE_LENGTH = STRLEN( EMAIL_ATTACHMENT ).
header - attachment
  if attachment_header is initial.
    HEADER = 'ATTACH'.
  else.
    header = attachment_header.
    endif.
  APPEND HEADER.
packing list - row for attachment
  CLEAR PACKLIST.
  case attachment_doc_type.
   when 'XLS'.
     PACKLIST-TRANSF_BIN = 'X'.
    when others.
      PACKLIST-TRANSF_BIN = SPACE.
    endcase.
  PACKLIST-HEAD_START = 2.
  PACKLIST-HEAD_NUM   = 1.
  PACKLIST-BODY_START = NEXT_ROW.
  if not attachment_doc_type is initial.
    packlist-doc_type   = attachment_doc_type.
  else.
    PACKLIST-DOC_TYPE   = 'RAW'.
    endif.
packlist-doc_type   = 'EXT'.
  PACKLIST-OBJ_DESCR  = ATTACHMENT_SUBJECT.
  PACKLIST-OBJ_NAME   = 'ATTACHMENT'.
  PACKLIST-BODY_NUM   = LINES.
  D_DOC_SIZE = LAST_LINE_LENGTH + ( 255 * ( LINES - 1 ) ).
  PACKLIST-DOC_SIZE   = D_DOC_SIZE.
  APPEND PACKLIST.
  ENDIF. "attachment
document
document-obj_name = 'EMAIL'.
DOCUMENT-OBJ_DESCR = EMAIL_SUBJECT.
document-obj_langu = sy-langu.
document-obj_expdat = sy-datum.
document-sensitivty = 'F'.
document-obj_prio = 9.
document-no_change = 'X'.
document-priority = 9.
document-expiry_dat = sy-datum.
ADD 1 TO: DOCUMENT-OBJ_EXPDAT, DOCUMENT-EXPIRY_DAT.
DESCRIBE TABLE contents LINES lines.
D_DOC_SIZE = LAST_LINE_LENGTH + ( 255 * ( LINES - 1 ) ).
document-doc_size = d_doc_size.
call the mail function
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     EXPORTING
          document_data              = document
        put_in_outbox              = 'X'
          commit_work                = 'X'
     TABLES
          object_header              = header
          packing_list               = packlist
          contents_txt               = contents
          receivers                  = 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.
IF SY-SUBRC > 0.
  RAISE ERROR_SENDING_MAIL.
  ENDIF.
ENDFUNCTION.
Also remember that the SAP user sending the email must have an email address in the user details, so that SAP has something to put in the "From" field when creating the email.
That's why we use this:
FUNCTION Z_USER_EMAIL_ADDRESS.
""Local interface:
*"  IMPORTING
*"     REFERENCE(USER_NAME) TYPE  SYUNAME DEFAULT SY-UNAME
*"  EXPORTING
*"     REFERENCE(EMAIL_ADDRESS) TYPE  AD_SMTPADR
*"  EXCEPTIONS
*"      UNKNOWN_USER
*"      NO_ADDRESS_KEY
*"      NO_ADDRESS_DATA
*"      NO_EMAIL_ADDRESS
tables:
  adr6,
  usr21,
  usr02.
SAP logon data
select single *
  from usr02
  where bname = user_name.
if sy-subrc ne 0.
  message i017(ZREP) with
    'SAP user' user_name 'is unknown'
    raising unknown_user.
  endif.
SAP user address key
select single *
  from usr21
  where bname = user_name.
if sy-subrc ne 0.
  message i017(ZREP) with
    'No address data assigned to SAP user' user_name
    raising no_address_key.
  endif.
SAP user address
select single *
  from adr6
  where addrnumber = usr21-addrnumber and
        persnumber = usr21-persnumber.
if sy-subrc ne 0.
  message i017(ZREP) with
    'No address data found for SAP user' user_name
    raising no_address_data.
  endif.
email_address = adr6-smtp_addr.
if email_address is initial.
  message i017(ZREP) with
    'No address data found for SAP user' user_name
    raising no_email_address.
  endif.
ENDFUNCTION.
John

Similar Messages

  • How do I scan a photo to a file and then send the file as an attachment via email.

    How do I scan a photo to a file and then send the file as an attachment  via email.

    All of this depends largely on what printer /software you have, which Email client you use and to some extent which OS you are running.
    Most HP printers have HP Solution Center which is used to set up scanning,choosing where to save,etc. Once a file/photo is scanned and saved to the folder, open the folder.Select the file and at the top of the window should be the option to 'Email'.
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • Problem in sending the file as an attachment through mail

    Hi,
    I have developed a Zreport. The functionality is like on executing this report it should send an e-mail with an attachment of the data in the xcel format.
    So, while execting this report in background mode in ECC 5.0, it is able to send the mail as an attachment but the file doesn't contain the data in it But, the same report while trying to execute in back ground mode in ECC 6.0, it is able to send the mail with the attachment and the file also has the data.
    So, my question is like are there any patches that has to be installed in ECC 5.0 system to get this successfully done.
    Thanks in advance for your answers.
    Rohith

    Hello,
    Are you using the standad sap function module or using OLE objects to generate excel?
    First try creating the excel file in foreground and see if the data is being populated.
    Kind Regards,
    Niky.

  • How to send PDF file as an attachment in email?

    Hi Folks,
    I have successfully configured SMTP and by now I can successfully send normal text messages along with .TXT files. However, when I am trying to send an email along with .pdf file as an attachment, I am getting the mail in my inbox, but I cannot open the .pdf file! I am getting the following Acrobat error:
    Acrobat could not open 'abc.pdf' because it is either not a supported file type or because the file has been corrupted
    Can any help me in solving this problem?
    Thanks in advance
    Regards,
    Faisal

    Hi Vajha,
    Thanks alot for your kind reply. I also express my apologies for responding to your reply lately.
    I beleive all the links you have sent me are talking about ABAP coding. what I am interested in is,
    is there any configuration that I am missing in SCOT (Basis side)?
    Since I am not an ABAPER, so I carry out these activities.
    Can anyone please answer the following queries of mine:
    1. Can't we send any PDF attachment in a mail from R/3?
    2. Do we have to do it through coding only?
    3. In scot we have option "All formats except fllw". But it does not work for me. Any inputs?
    Thanks in advance.
    Regards,
    Faisal

  • How to send pdf files from local dir through emails attachments

    I have some pdf documents in some directory, I want to send those pdf's as an attachment throu emails to the concerned person.
    Please let me know how to attach the files and send through email.
    Thanks.

    You are using Forms 4.5, which is a client/server configuration. When you create a pdf file, the file has to be written to a directory that is accessible from your PC. D:\ is acessible, /tmp/ not (that is a directory on some Unix server). If you want to write files to a Unix server, you have to set up Samba and map a drive from your PC to he Unix directory.
    Since you are creating multiple pdf files, you will have to wait until all reports are finished and mail them afterwards. You can create a batch script to mail the files.

  • Sending excel file as an attachment  in email program thru Oracle8i

    I cant send my excel file as an attachment in my email program thru Oracle 8i.
    My excel file i located in my local pc C:\test.xls
    Everything is in my local machine, DB and progams.
    I have read the example of DEMO_MAIL program i am hardly understand it.
    My sample program:
    if (p_file_name is not null) then
    begin_attachment( p_mime_type=>'application/excel',               p_fname=>p_file_name,
         p_transfer_enc=>'base64'
         dbms_lob.createtemporary(l_blob, true);
         dbms_lob.open(l_bfile);
         dbms_lob.fileopen(l_bfile);
         dbms_lob.open(l_blob, dbms_lob.lob_readwrite);
         dbms_lob.loadfromfile(l_blob, l_bfile, dbms_lob.getlength(l_bfile));
         dbms_lob.fileclose(l_bfile);
         dbms_lob.close(l_bfile);
         l_file_len := dbms_lob.getlength(l_blob);
         l_modulo := mod(l_file_len,MAX_BASE64_LINE_WIDTH);
         l_pieces := trunc(l_file_len/MAX_BASE64_LINE_WIDTH);
    while (l_counter < l_pieces)
    loop
    dbms_lob.read(l_blob, l_modulo, l_filepos, l_buffer);
    l_message := utl_raw.concat(l_message, l_buffer);
    write_mb_text(l_message||g_crlf);
    l_filepos := l_counter * MAX_BASE64_LINE_WIDTH + 1;
    l_counter := l_counter + 1;
    end loop;
    if l_modulo <> 0 then
    dbms_lob.read(l_blob, l_modulo, l_filepos, l_buffer);
    l_message := utl_raw.concat(l_message, l_buffer);
    write_mb_text(l_message||g_crlf);
    end if;
    dbms_lob.close(l_blob);
    end_attachment(true);     
    Please help

    I did not receive any error messages when executing the program. It works fine, I received the email nicely but without the attachment.
    Here is the emails I received:
    LOGICAL SPACE USED HAS REACHED ITS TRESHOLD. PLEASE DO NECESSAY TO MAKE MORE ROOM FOR THE SPACE TO EXTEND.
    Tablespace Name Used Size(MB) Free Size(MB)
    SYSTEM 259.953 4.047
    USERS 144.508 55.492
    INDX 31.258 26.742
    -------7D81B75CCC90D2974F7A1CBD
    Content-Type: multipart/mixed; boundary="-----7D81B75CCC90D2974F7A1CBD"
    Content-Disposition: attachment; filename="capacity_13-JAN-05-111226.xls"
    Content-Transfer-Encoding: base64
    -haris

  • Sending ALV report(As a attachment ) through EMail

    Dear Friends,
    Could anyone please help me to solve this problem.
    I need to send ALV report <b>as an attachment</b> to External mail-id as well as SAP USER ID..The user wants to schedule this ABAP program in background, at the end the final output should be send to his ID. I facing problem to locate correct Functional Module....
    I would like to thank, if anyone give some idea on this issue also if possible a sample code.
    Thanks in advance
    With Reg
    Babu

    HI Kamal Babu
    After sending your ABAP List to the spool request (SP01), you can use the SAP standard spool PDF conversion program.
    RSTXPDFT4 - This report program converts ABAP List to PDF files.
    Or Just try this sample code:
    After running the background jobs, send the spool to the SAP users Office Mail Box.
    REPORT ZMAILSPOOL.
    INCLUDE LBTCHDEF.
    Include the Business Object Repository object
    INCLUDE <CNTN01>.
    DATA ABAPNM LIKE SY-REPID.
    DATA BEGIN OF LOCAL_JOB.
    INCLUDE STRUCTURE TBTCJOB.
    DATA END OF LOCAL_JOB.
    DATA BEGIN OF LOCAL_STEP_TBL OCCURS 10.
    INCLUDE STRUCTURE TBTCSTEP.
    DATA END OF LOCAL_STEP_TBL.
    Data declarations for the mail recipient
    DATA RECIPIENT TYPE SWC_OBJECT.
    DATA RECIPIENT_OBJ LIKE SWOTOBJID.
    SWC_CONTAINER CONTAINER.
    Data declarations for the background job
    PARAMETERS ABAPNAME(20) DEFAULT 'ZTEST1'.
    PARAMETERS EMPFNAME LIKE SY-UNAME DEFAULT SY-UNAME.
    ABAPNM = ABAPNAME.
    LOCAL_JOB-JOBNAME = ABAPNAME.
    Generate recipient object (see report RSSOKIF1 for an example)
    1. Create the recipient:
    IF EMPFNAME <> SPACE.
    "** 1.1 Generate an object reference to a recipient object
    SWC_CREATE_OBJECT RECIPIENT 'RECIPIENT' SPACE.
    "** 1.2 Write the import parameters for method
    "** recipient.createaddress into the container
    "** and empty the container
    SWC_CLEAR_CONTAINER CONTAINER.
    "** Set address element (internal user 'JSMITH')
    SWC_SET_ELEMENT CONTAINER 'AddressString' EMPFNAME.
    "** Set address type (internal user)
    SWC_SET_ELEMENT CONTAINER 'TypeId' 'B'.
    "** 1.3 Call the method recipient.createaddress
    SWC_CALL_METHOD RECIPIENT 'CreateAddress' CONTAINER.
    "** Issue any error message generated by a method exception
    IF SY-SUBRC NE 0.
    MESSAGE ID SY-MSGID TYPE 'E' NUMBER SY-MSGNO.
    ENDIF.
    SWC_CALL_METHOD RECIPIENT 'Save' CONTAINER.
    SWC_OBJECT_TO_PERSISTENT RECIPIENT RECIPIENT_OBJ.
    ENDIF.
    Recipient has been generated and is ready for use in a
    background job
    CALL FUNCTION 'JOB_OPEN'
         exporting
         DELANFREP              = ' '
         JOBGROUP               = ' '
           jobname                = LOCAL_JOB-JOBNAME
         SDLSTRTDT              = NO_DATE
         SDLSTRTTM              = NO_TIME
         IMPORTING
           JOBCOUNT               = LOCAL_JOB-JOBCOUNT
         EXCEPTIONS
           CANT_CREATE_JOB        = 1
           INVALID_JOB_DATA       = 2
           JOBNAME_MISSING        = 3
           OTHERS                 = 4
       if sy-subrc <> 0.
          WRITE: / 'JOB_OPEN PROBLEM ', SY-SUBRC.
       ELSE.
          WRITE: / 'JOB OPEN SUCCESS',
                                      LOCAL_JOB-JOBNAME, LOCAL_JOB-JOBCOUNT.
       endif.
    CALL FUNCTION 'JOB_SUBMIT'
         exporting
         ARCPARAMS                         =
           authcknam                         = SY-UNAME
         COMMANDNAME                       = ' '
         OPERATINGSYSTEM                   = ' '
         EXTPGM_NAME                       = ' '
         EXTPGM_PARAM                      = ' '
         EXTPGM_SET_TRACE_ON               = ' '
         EXTPGM_STDERR_IN_JOBLOG           = 'X'
         EXTPGM_STDOUT_IN_JOBLOG           = 'X'
         EXTPGM_SYSTEM                     = ' '
         EXTPGM_RFCDEST                    = ' '
         EXTPGM_WAIT_FOR_TERMINATION       = 'X'
           jobcount                          = LOCAL_JOB-JOBCOUNT
           jobname                           = LOCAL_JOB-JOBNAME
         LANGUAGE                          = SY-LANGU
         PRIPARAMS                         = ' '
           REPORT                            = ABAPNM
         REPORT                            = 'ZTEST1'
         VARIANT                           = ' '
       IMPORTING
         STEP_NUMBER                       = LOCAL_JOB-STEPCOUNT
         EXCEPTIONS
           BAD_PRIPARAMS                     = 1
           BAD_XPGFLAGS                      = 2
           INVALID_JOBDATA                   = 3
           JOBNAME_MISSING                   = 4
           JOB_NOTEX                         = 5
           JOB_SUBMIT_FAILED                 = 6
           LOCK_FAILED                       = 7
           PROGRAM_MISSING                   = 8
           PROG_ABAP_AND_EXTPG_SET           = 9
           OTHERS                            = 10
       if sy-subrc <> 0.
          WRITE: / 'JOB_SUBMIT PROBLEM ', LOCAL_JOB-JOBCOUNT,
                   LOCAL_JOB-JOBNAME, ABAPNAME, SY-SUBRC.
       endif.
    IF EMPFNAME <> SPACE.
    CALL FUNCTION 'JOB_CLOSE'
      exporting
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = LOCAL_JOB-JOBCOUNT
        jobname                           = LOCAL_JOB-JOBNAME
      LASTSTRTDT                        = NO_DATE
      LASTSTRTTM                        = NO_TIME
      PRDDAYS                           = 0
      PRDHOURS                          = 0
      PRDMINS                           = 0
      PRDMONTHS                         = 0
      PRDWEEKS                          = 0
      PREDJOB_CHECKSTAT                 = ' '
      PRED_JOBCOUNT                     = ' '
      PRED_JOBNAME                      = ' '
      SDLSTRTDT                         = NO_DATE
      SDLSTRTTM                         = NO_TIME
      STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
        STRTIMMED                         = 'X'
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
        RECIPIENT_OBJ                     = RECIPIENT_OBJ
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
    IMPORTING
      JOB_WAS_RELEASED                  = 'X'
      EXCEPTIONS
        CANT_START_IMMEDIATE              = 1
        INVALID_STARTDATE                 = 2
        JOBNAME_MISSING                   = 3
        JOB_CLOSE_FAILED                  = 4
        JOB_NOSTEPS                       = 5
        JOB_NOTEX                         = 6
        LOCK_FAILED                       = 7
        OTHERS                            = 8
    IF ( SY-SUBRC <> 0 ).
      WRITE: / 'Job_Close Problem:', ABAPNAME, SY-SUBRC.
    ELSE.
      WRITE: / 'Job_Close done'.
    ENDIF.
    ELSE. "no empfname
    ENDIF.
    Cheers,
    Vijay Raheja

  • How to send zip file as attachment through email

    Hi All,
    I am having a requirement that I need to download the internal table data into .txt file and I need to zip the text file. And this zip files needs to send to the customer through email.
    I am able download the data into .txt and able to zip the file. But I am not able send the .zip file through email.
    I know that we can send .xls, .txt, .csv and also .ppt, .doc file types we can send as an attachement through abap program. But I don't know about .zip files. Is there any possibilty to send .zip file as an attachment thorugh email.
    Can any one help me how to send a .zip file thorugh email as an attachment. 
    Regards,
    vinod

    hi Vinod,
    Can you please tell me how you have zipped the file.
    I am having a text file in application server. I need to zip that file. Then the middleware moves it to Legacy system.
    I used the following code. With this I am having the data in Binary format which my midleware cannot understand.
    What I need on the whole is just to reduce the size of the file.
    form ZIP_FILE .
    DATA: lt_data TYPE TABLE OF x255,
          lt_textdata TYPE TABLE OF x255.
    DATA: ls_data LIKE LINE OF lt_data.
    DATA: lv_dsn1(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEX.TXT'.
    DATA: lv_dsn3(100) VALUE '/ECD/120/GIS/FTP/IB/DNBPAYDEXZIP.zip'.
    *DATA: lv_dsn3(100) VALUE '/interfaces/SM5/test.zip'. " Contains sample1.xls and sample2.xls
    DATA: lv_file_length TYPE i.
    DATA: lv_content TYPE xstring.
    DATA: lo_zip TYPE REF TO cl_abap_zip.
    CREATE OBJECT lo_zip.
    Read the data as a string
    clear lv_content .
    OPEN DATASET lv_dsn1 FOR INPUT IN BINARY MODE.
    READ DATASET lv_dsn1 INTO lv_content .
    CLOSE DATASET lv_dsn1.
    lo_zip->add( name = 'sample.TXT' content = lv_content ).
    lv_content = lo_zip->save( ).
    *clear lv_content .
    Conver the xstring content to binary
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer = lv_content
    IMPORTING
    output_length = lv_file_length
    TABLES
    binary_tab = lt_data.
    OPEN DATASET lv_dsn3 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    LOOP AT lt_textdata INTO ls_data.
    TRANSFER ls_data TO lv_dsn3.
    ENDLOOP.
    CLOSE DATASET lv_dsn3.
    IF sy-subrc EQ '0'.
        MESSAGE s999(zfi_ap_gl) WITH text-t10.
      ENDIF.
    Can you please help.
    Thanks Aravind

  • Convert spool to xls and send the attachment through email

    Hello,
    I have a requirement to convert spool to xls and then send the xls as an attachment through email,how sould i go about it,which fm can i use please advice..
    Thanks.

    Please check the links
    Re: Spool to XLS
    Re: converting spool data to xls file format.
    Regards
    Satish Boguda

  • Sending smartform as PDF attachment through email

    Hi,
    I have used the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the smartform as PDF attachment through email.In SOST transaction I can see that the mail has been sent to the reciepient,but the mail is not going to the mail box.What would be the reason for this?
    Regards,
    Hema

    That should be the basis issue. They needs to do some settings. Please ask them to do so.
    Pranav

  • Send mails with csv file as an attachment through oracle(SQL SCripts / Stor

    Hello Everybody,
    I have recently come across a requirement in which I am supposed to send mails with csv file as an attachment through oracle(SQL SCripts / Stored Procedure) .
    The contents of the csv file are to be retreived from the Database as well as the content of the mail and to whom it needs to be sent has also to be picked up from the database.
    Can somebody suggest me with a suitable code for the same?
    Would be of great help..!!
    Thanks & Regards,
    - VR
    Edited by: user646716 on Dec 18, 2009 10:44 AM

    read below links
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:255615160805
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL#Send_mail_with_UTL_TCP_-withattachments
    How to send csv file as an attachment

  • How to send txt file  as attachement in email

    Hi Experts ,
    How to send  txt file  as attachement in email .
    which function module i use

    Hi,
    Try to use this one
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    Hope it can solve your problem!
    Good luck!
    Tao

  • How to send csv file as an attachment

    Hi,
    I am able to create a csv file in this directory as "test.scv" using utl_file and some select statements.
    Now I need to send this csv file as an attachment in email.
    we have smtp installed on our server.
    Please help me on this .
    Thanks
    Kind Regards

    The first link takes in a filename (this would be the csv file you have already created) so nothing should be hard coded; it's just the parameters you pass in.
    Doing a little more research (from the asktom article I posted previously) links to this [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html] which the real gold is at [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/maildemo_sql.txt]:
    with examples how to use it at [http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/mailexample_sql.txt].
    To get the attachments working from a PL/sql application you will require one of the packages or a large amount of code.
    here's the coded example for attaching files from the packages listed in maildemo_sql.txt from Oracle's website
    REM Send an email with 2 attachments.
    DECLARE
      conn      utl_smtp.connection;
      req       utl_http.req; 
      resp      utl_http.resp;
      data      RAW(200);
    BEGIN
      conn := demo_mail.begin_mail(
        sender     => 'Me <[email protected]>',
        recipients => 'Someone <[email protected]>',
        subject    => 'Attachment Test',
        mime_type  => demo_mail.MULTIPART_MIME_TYPE);
      demo_mail.attach_text(
        conn      => conn,
        data      => '<h1>Hi! This is a test.</h1>',
        mime_type => 'text/html');
      demo_mail.begin_attachment(
        conn         => conn,
        mime_type    => 'image/gif',
        inline       => TRUE,
        filename     => 'image.gif',
        transfer_enc => 'base64');
      -- In writing Base-64 encoded text following the MIME format below,
      -- the MIME format requires that a long piece of data must be splitted
      -- into multiple lines and each line of encoded data cannot exceed
      -- 80 characters, including the new-line characters. Also, when
      -- splitting the original data into pieces, the length of each chunk
      -- of data before encoding must be a multiple of 3, except for the
      -- last chunk. The constant demo_mail.MAX_BASE64_LINE_WIDTH
      -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
      -- of data before encoding.
      req := utl_http.begin_request('http://www.some-company.com/image.gif');
      resp := utl_http.get_response(req);
      BEGIN
        LOOP
          utl_http.read_raw(resp, data, demo_mail.MAX_BASE64_LINE_WIDTH);
          demo_mail.write_raw(
            conn    => conn,
            message => utl_encode.base64_encode(data));
        END LOOP;
      EXCEPTION
        WHEN utl_http.end_of_body THEN
          utl_http.end_response(resp);
      END;
      demo_mail.end_attachment( conn => conn );
      demo_mail.attach_text(
        conn      => conn,
        data      => '<h1>This is a HTML report.</h1>',
        mime_type => 'text/html',
        inline    => FALSE,
        filename  => 'report.htm',
        last      => TRUE);
      demo_mail.end_mail( conn => conn );
    END;
    /Edited by: tanging on Dec 18, 2009 10:58 AM

  • How to pass .txt file as an attachment to the web service (SOAP Attachment)

    Hi,
    I am creating web service using NetBeans 6.5 IDE and JAX-WS. I create a web application and then create web service using provided interface. I want to add .txt file as an attachment/parameter to the web service operation using "Add operation" interface. Don't want to add as an attachment to the SOAP message by creating it explicitly. IDE generates SOAP request and response automatically when the service is tested using "Test Web service" option. How can I add attcahment when I add operation so that it will appear in the generated SOAP message ?
    TIA.

    Hi AnitaDP,
    Attachment doesn't work in web service. You have to pass the content of the text file as a String or as an array of bytes to a method of your web service. From there, you may save the passed data in a file.

  • How to send a file as an attachment using mailx

    Hi
    Can any one tel me how to send a file as an attachment using mailx command in shell script.
    Thanks,
    Suman.

    Wrong forum where to ask such questions.
    Check this one link:
    http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254

Maybe you are looking for