Bug sending email with Excel file (immediate reply would he helpfull)

Hi ,
   Below is have pasted a sample code where it will sends a email along with an attachtment (xls) .where the email is working perfectly but the xls file attachtment has a blank space in the first line .
where iam facing the problem ,
ie there should not be any blank lines at the top .
Please run the code one i have pasted below .u can find the bug .
can any one help me on this .
please have ur mail id in ( reclist-receiver ) so that u can check for the output.
This table requires information about how the data in the
tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
to be distributed to the documents and its attachments.
DATA: objpack LIKE sopcklsti1 OCCURS  2 WITH HEADER LINE.
This table must contain the summarized data dependent on each object type.
SAPscript objects store information here about forms and styles,
for example. Excel list viewer objects store the number of rows and columns
amongst other things and PC objects store their original file name.
DATA: objhead LIKE solisti1   OCCURS  1 WITH HEADER LINE.
*CREATION OF INTERNAL TABLE
DATA : BEGIN OF itobjbin OCCURS 10 ,
       vbeln type vbrp-vbeln,
       matnr type vbrp-matnr,
       werks type vbrp-werks,
       fktyp like vbrk-fktyp,
       END OF itobjbin .
This table must contain the summarized content of the objects identified as binary objects.
*DATA: OBJBIN  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
DATA:   objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
               WITH HEADER LINE.
DATA: wa_itobjbin LIKE itobjbin .
This table must contain the summarized content of the objects identified as ASCII objects.
DATA: objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
This table must contain the document recipients.
DATA: reclist LIKE somlreci1  OCCURS  5 WITH HEADER LINE.
This structure must contain the attributes of the document to be sent.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA : V_FKTYP LIKE VBRK-FKTYP.
Creating the document to be sent
doc_chng-obj_name = 'OFFER'.                      " input contains the attributes of the document to be sent
doc_chng-obj_descr = 'EMAIL WITH EXCEL DOWNLOAD'.   "input contains title/subject of the document
*BODY OF THE MAIL
OBJTXT = 'Hi'.
APPEND OBJTXT .
OBJTXT = 'Test for excel download'.
APPEND OBJTXT.
OBJTXT = 'Below is the attachment with Billing Document Details'.
APPEND OBJTXT.
OBJTXT = 'Regards'.
APPEND OBJTXT.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
Creating 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.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
select vbeln matnr werks
        from vbrp into table itobjbin
        up to 10 rows
        where werks GE '1000'.
loop at itobjbin.
select single fktyp into  v_fktyp from vbrk where vbeln = itobjbin-vbeln.
move v_fktyp to itobjbin-fktyp.
modify itobjbin.
endloop.
PERFORM build_xls_data_table .
DESCRIBE TABLE objbin LINES tab_lines.
objhead = 'ABC.XLS'. APPEND objhead.
Creating 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   = 'XLS'.
objpack-obj_name   = 'ATTACHMENT'.
objpack-obj_descr = 'XLS'.
objpack-doc_size   = tab_lines * 255.
APPEND objpack..
Entering names in the distribution list
reclist-receiver = ''.
reclist-rec_type = 'U'.
APPEND reclist.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
     EXPORTING
          document_data = doc_chng
          put_in_outbox = 'X'
          commit_work   = 'X'
     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 'sent successfully'.
      ELSE.
        WRITE 'not sent'.
      ENDIF.
    ENDLOOP.
  WHEN 1.
    WRITE: / 'no authorization to send to the specified number of',  'recipients!'.
  WHEN 2.
    WRITE: / 'document could not be sent to any of the recipients!'.
  WHEN 4.
    WRITE: / 'no authorization to send !'.
  WHEN OTHERS.
    WRITE: / 'error occurred during sending !'.
ENDCASE.
*&      Form  build_xls_data_table
      text
-->  p1        text
<--  p2        text
FORM build_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
           con_tab TYPE x VALUE '09'.   "OK for non Unicode
CONCATENATE 'Billing Document' 'Material Number' 'Plant' 'Billing category' ' ' INTO objbin SEPARATED BY con_tab.
CONCATENATE con_cret objbin  INTO objbin.
APPEND  objbin.
LOOP AT itobjbin  .
   CONCATENATE itobjbin-vbeln itobjbin-matnr itobjbin-werks itobjbin-fktyp' '
          INTO objbin SEPARATED BY con_tab.
   CONCATENATE con_cret objbin  INTO objbin.
   APPEND  objbin.
ENDLOOP.
thanks in advance,
vinay .

Hi ravi ,
     Thanks ,for your help .now xls is working fine .
but now iam facing a problem with the same function module .for txt files .where all the records are formated in asingle line .
can u provide a solution for this ,which would be very helpfull.
below is have attached the sample code .
Thanks,
vinay.
FUNCTION Z_KAILASH_ATTACHMENT1.
""Local Interface:
*"  IMPORTING
*"     VALUE(EMAILID)
*"     VALUE(SUBJECT)
*"     VALUE(ATYPE)
*"  TABLES
*"      ATTACH_FILE STRUCTURE  SOLISTI1
*"      BODY OPTIONAL
This table requires information about how the data in the
tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
to be distributed to the documents and its attachments.
  DATA OBJPACK LIKE SOPCKLSTI1 OCCURS  2 WITH HEADER LINE.
This table must contain the summarized data dependent on each object type.
SAPscript objects store information here about forms and styles,
for example. Excel list viewer objects store the number of rows and columns
amongst other things and PC objects store their original file name.
  DATA OBJHEAD LIKE SOLISTI1   OCCURS  1 WITH HEADER LINE.
This table must contain the summarized content of the objects identified as binary objects.
  DATA   OBJBIN TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                 WITH HEADER LINE.
This table must contain the summarized content of the objects identified as ASCII objects.
  DATA OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
This table must contain the document recipients.
  DATA  RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE .
This structure must contain the attributes of the document to be sent.
  DATA: DOC_CHING LIKE SODOCCHGI1.
  DATA: TAB_LINES LIKE SY-TABIX.
Create the internal table for body , subject
  DATA: IT_BODY LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
           con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
Move Body to Internal Table (body into it_body)
  LOOP AT BODY .
    MOVE BODY TO IT_BODY .
    APPEND IT_BODY .
  ENDLOOP.
  DOC_CHING-OBJ_DESCR = SUBJECT.   "Subject of the Email
Move the Subject and Body to OBJTXT
  OBJTXT[] = IT_BODY[].
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHING-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
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.
Convert IT to Excel format
IF ATYPE = 'XLS' .
*CONSTANTS: con_cret TYPE C VALUE cl_abap_char_utilities=>horizontal_tab,
          con_tab TYPE C VALUE cl_abap_char_utilities=>cr_lf.
  LOOP AT ATTACH_FILE .
    REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_cret. "  INTO objbin.
    CONCATENATE  ATTACH_FILE con_tab INTO objbin.
    APPEND  objbin.
  ENDLOOP.
ELSEIF ATYPE = 'TXT' .
  LOOP AT ATTACH_FILE .
    REPLACE ALL OCCURRENCES OF '#' IN ATTACH_FILE WITH con_tab. "  INTO objbin.
    CONCATENATE ATTACH_FILE ' '  INTO OBJBIN .
    APPEND OBJBIN .
  ENDLOOP.
ENDIF.
****End-Code Excel Format .
DESCRIBE TABLE objbin LINES tab_lines.
objhead = subject. APPEND objhead.
Creating 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   = ATYPE.
objpack-obj_name   = 'ATTACHMENT'.
objpack-obj_descr = 'TEST'. "Attachment File Name
objpack-doc_size   = TAB_LINES * 255.
APPEND objpack..
reclist-receiver = EMAILID.
reclist-rec_type = 'U'.
APPEND reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
  EXPORTING
   DOCUMENT_DATA                    = DOC_CHING
   PUT_IN_OUTBOX                    = 'X'
   COMMIT_WORK                      = 'X'
IMPORTING
  SENT_TO_ALL                     =
  NEW_OBJECT_ID                   =
  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 .
ENDFUNCTION.

Similar Messages

  • Sending email with excel file as an attachment

    Hi,
    In my procedure I am creating one excel file and keeping that excel file in one location as specified in UTL_FILE_DIR.Now my requirement is to pick that excel file from that path and send it as an attachment through an Email.
    Can anyone please give me the code to do that and what are the required set up to be done before sending the mail.
    Please help me in this regard. This is an urgent requirement.
    Thanks
    Subhabrata

    Hi,
    Please refer the following link:
    http://www.dbasupport.com/oracle/ora10g/10g_PLSQL02.shtml
    There is para headed Sending E-Mail and Attachments with UTL_MAIL will clarify all your doubts. Link Listing 2.6
    is good example.
    If you get stuck while coding, get back to us.
    Twinkle

  • Shell Script to send email with .txt file as attachment

    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!

    978334 wrote:
    Dear Al,
    Could any one help me with code, for sending email with .txt file as attachment using shell script.
    Thank You!http://bit.ly/XHfSCz
    https://forums.oracle.com/forums/search.jspa?threadID=&q=sendmail&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Send Email with Excel attachment with formatting(bold, color) in Background

    Hi,
    I have requirement wherein I have to send an email with excel attachment with proper formatting of certain fields in the excel sheet like making it bold or setting different color. The data is available in an internal table. Just to to format it and send an email when the program is executed in background mode.
    Any pointers on this would be highly appreciated!
    Thanks,
    Anil.

    I  resolved my own problem using the BCS_EXAMPLE_7 program as sample.

  • Send email with txt file as attachment

    Hi ,
    can any one help me in download as txt file using the function module SO_OBJECT_SEND along with email .
    a sample code using this function module would be helpfull.
    Thanks,
    vinay .

    Hi vinay,
    Not only TXT file, u can send any
    other file like word,excel,pdf,exe, etc.
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    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 ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • Send email with excel attachement

    I'm using SO_DOCUMENT_SEND_API1 function to send a scheduled email with attachment.
    But the problem is that the length of the string that I'm appending to the excel exceeds 256 characters.
    So, the final excel file has trimmed values. Meaning only the first 255 characters are displayed.
    I hope you guys understand what i'm saying.
    So as I found out it seems that the above function can't be used in my case.
    Do you know any other way of sending an email with attachment that meets my requirements.
    Thanks,
    Thilanka.

    Hi Buddy,
       I also came across the same problem once. The only solution to this is tell your client to reduce the fields lenght which are not require.
       Only 255 Char can be send on mail as per the fun Mod.
       you have to reduce the length or display some  data in the body of mail.
    Hope this will solve your worry...
    Thanks,
    Krishna..

  • Issue in Sending email with EXCEL attachment

    Hi,
    Im using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending emails to a list of recipients with an excel attachment. In the attachment data, as the field length is 255 for the structure SOLISTI1, for the records having more than 255 characters, data is being truncated. I did a search in this forum and done some changes , still it is not working properly.
    I have used SCMS_TEXT_TO_XSTRING, SCMS_XSTRING_TO_BINARY FMs for converting the data to hexa format. This case, records having more than 255 are displayed properly in the attachment, but there are blank lines inserted between two records.
    Please suggest me to resolve this isssue.
    Thanks in advance.
    Jayashree

    Hi Jayashree,
    you might want to check out the example link by Saso in his post Send external email from within ABAP program to xls.
    For the rest I can only guess that there might be some issues with the format you use for Excel. In case of empty lines and using a text format for Excel the issue is in most cases that there are too many carriage return line feeds in the text fiel (cl_abap_char_utilities=>cr_lf).
    Hope that helps.
    Best Regards
    Michael

  • Send email with excel attachment in outlook structure - SAP 6.0

    Hello experts..
    I need send a email with a excel attachment and use the signature in outlook to send.
    The attachment will be create in the process of send email program.
    Is it possible?
    How can I created and attach in the same process?
    How can I use the outlook strutucture to send a email?

    I  resolved my own problem using the BCS_EXAMPLE_7 program as sample.

  • Sending email with excel attachment from an ABAP report

    Hello All,
    I am using the function module SO_DOCUMENT_SEND_API1 to send an e-mail with an excel attachment.
    The code works fine for  less than 255 characters in each row of excel file.But for more than 255 characters , the excel file received has data upto 255 characters only.
    Can someone please suggest how to send excel file with more than 255 characters in each row ?
    Regards,
    KK

    check below code
    FORM excelrep .
      DATA :l_syuzeit TYPE sy-uzeit,
            l_time(5) TYPE c,
            l_ampm(2) TYPE c,
            l_subject(255) TYPE c.
      CLEAR t_xls.
      REFRESH t_xls.
      l_syuzeit = sy-uzeit.
      IF t_final_data1[] IS NOT INITIAL.
        PERFORM fill_header.
        LOOP AT t_final_data1 WHERE status NE space.
          t_xls-jobname = t_final_data1-jobname.
          WRITE t_final_data1-act_start_date TO t_xls-act_start_date.
          WRITE t_final_data1-est_start_time TO t_xls-est_start_time.
          WRITE t_final_data1-act_start_time TO t_xls-act_start_time.
          WRITE t_final_data1-est_end_time TO t_xls-est_end_time.
          WRITE t_final_data1-act_end_time TO t_xls-act_end_time.
          t_xls-est_duration = t_final_data1-est_duration.
          t_xls-act_duration = t_final_data1-duration.
          t_xls-status = t_final_data1-comment.
          t_xls-process = t_final_data1-desc.
          t_xls-fill10 = c_0d.
          t_xls-fill1 = c_09.
          t_xls-fill2 = c_09.
          t_xls-fill3 = c_09.
          t_xls-fill4 = c_09.
          t_xls-fill5 = c_09.
          t_xls-fill6 = c_09.
          t_xls-fill7 = c_09.
          t_xls-fill8 = c_09.
          t_xls-fill9 = c_09.
          APPEND t_xls.
          CLEAR t_xls.
        ENDLOOP.
        l_ampm = c_am.
        IF l_syuzeit GT c_125959.
          l_syuzeit = l_syuzeit - c_120000.
          l_ampm = c_pm.
        ELSEIF l_syuzeit GT c_120000.
          l_ampm = c_pm.
        ELSEIF l_syuzeit LT c_010000.
          l_syuzeit = l_syuzeit + c_120000.
          l_ampm = c_am.
        ENDIF.
        WRITE l_syuzeit TO l_time USING EDIT MASK c_edmask.
        CONCATENATE text-070 l_time l_ampm INTO l_subject
                                      SEPARATED BY space.
        CLEAR w_doc_chng.
        w_doc_chng-obj_name = l_subject.
        w_doc_chng-obj_descr = l_subject.
        CLEAR t_objtxt.
        REFRESH t_objtxt.
        t_objtxt = text-068.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        t_objtxt = space.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        t_objtxt = text-069.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        t_objtxt = space.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        MOVE w_sysinfo TO t_objtxt.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        t_objtxt = space.
        APPEND t_objtxt.
        CLEAR t_objtxt.
        CLEAR w_tab_lines.
        DESCRIBE TABLE t_objtxt LINES w_tab_lines.
        w_doc_chng-doc_size = w_tab_lines * c_255.
        CLEAR t_objpack.
        REFRESH t_objpack.
        t_objpack-body_start = c_1.
        t_objpack-body_num = w_tab_lines * c_255.
        t_objpack-doc_type = c_txt.
        APPEND t_objpack.
        CLEAR t_objpack.
        CLEAR t_objbin.
        REFRESH t_objbin.
        LOOP AT t_xls.
          t_objbin = t_xls.
          APPEND t_objbin.
          CLEAR t_objbin.
        ENDLOOP.
        CLEAR w_tab_lines.
        DESCRIBE TABLE t_objbin LINES w_tab_lines.
        CLEAR l_subject.
        CONCATENATE text-083 sy-datum l_time l_ampm INTO l_subject
                    SEPARATED BY c_uscore.
        CLEAR t_objhead.
        REFRESH t_objhead.
        t_objhead = l_subject.
        APPEND t_objhead.
        CLEAR t_objhead.
        t_objpack-transf_bin = c_x.
        t_objpack-head_start = c_1.
        t_objpack-head_num = c_1.
        t_objpack-body_start = c_1.
        t_objpack-body_num = w_tab_lines.
        t_objpack-doc_type = c_xls.
        t_objpack-obj_name = text-070.
        t_objpack-obj_descr = text-070.
        t_objpack-doc_size = w_tab_lines * c_255.
        t_objpack-mess_type =  space.
        APPEND t_objpack.
        CLEAR t_objpack.
        CLEAR t_reclist.
        REFRESH t_reclist.
        IF s_email[] IS NOT INITIAL.
          LOOP AT s_email.
            t_reclist-receiver = s_email-low.
            t_reclist-rec_type = c_u.
            APPEND t_reclist.
            CLEAR t_reclist.
          ENDLOOP.
        ENDIF.
        PERFORM mail_report.
      ELSE.
        MESSAGE e015 WITH text-072.
      ENDIF.
      CLEAR : w_doc_chng,
              t_objpack,
              t_objhead,
              t_objbin,
              t_objtxt.
      REFRESH : t_objpack,
                t_objhead,
                t_objbin,
                t_objtxt,
                t_reclist.
    ENDFORM.                    " excelrep_criticaljobs
    *&      Form  mail_report
          text
    -->  p1        text
    <--  p2        text
    FORM mail_report .
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_chng
          commit_work                = c_x
        TABLES
          packing_list               = t_objpack
          object_header              = t_objhead
          contents_bin               = t_objbin
          contents_txt               = t_objtxt
          receivers                  = t_reclist
        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 NE 0.
        CASE sy-subrc.
          WHEN 1.
            MESSAGE i015 WITH text-071.
          WHEN 2.
            MESSAGE i015 WITH text-072.
          WHEN 4.
            MESSAGE i015 WITH text-073.
          WHEN OTHERS.
            MESSAGE i015 WITH text-074.
        ENDCASE.
      ELSE.
        MESSAGE s015 WITH text-081.
      ENDIF.
    ENDFORM.                    " mail_report

  • [HELP] Send email with attachment  files from application server

    How can i send email to users with pdf/xls attachment files through job with pl/sql , but the files are on application server.
    I've tried using UTL_MAIL but it's not working, cause the file & DIRectory setting should be inside of database server. Should I copy the files from report server to database file system or any other techniques so there's no need to use the physical files?
    Please help!
    Thank you

    Hi,
    Thanks for your help, hoek & alvinder...
    I've tried the java send mail suggest by alvinder, and i got an error if i fill the Sender parameter with AutoMail :
    status:1 javax.mail.SendFailedException: Sending failed;
    nested exception is:
         javax.mail.MessagingException: 553 5.5.4 <AutoMail>... Domain name required
    Then i changed the Sender with valid email address :
    status:1 javax.mail.SendFailedException: Sending failed;
    nested exception is:
         javax.mail.MessagingException: 501 5.1.8 Domain of sender address [email protected] does not exist
    What could be wrong with this? Please help me... since i dont understand java programming :)
    I 'm still trying to find out
    Thank you very much

  • How to use UTL_SMTP to send email with existing file attachment

    Hello! I am trying to create a pl/sql procedure that lets me send an email and include an existing file to a email address. So far, I found information on how to send a file and create an attachment with information I put in the procedure. This is NOT what I'm trying to do. I'm trying to send an email and include an attachment for a file that already exists. I need the pre-existing file to be sent to the email recipient.
    This is how far I've gotten, but this only allows me to CREATE an attachment with the information I put in it from the procedure. I got it from the following site:
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'Weekly Invoice Report';
       v_Mail_Host  VARCHAR2(30) := 'mail.mycompany.com';
       v_Mail_Conn  utl_smtp.Connection;
       crlf         VARCHAR2(2)  := chr(13)||chr(10);
    BEGIN
      v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
      utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
      utl_smtp.Mail(v_Mail_Conn, v_From);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
      utl_smtp.Data(v_Mail_Conn,
        'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
        'From: '   || v_From || crlf ||
        'Subject: '|| v_Subject || crlf ||
        'To: '     || v_Recipient || crlf ||
        'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
        'Content-Type: multipart/mixed;'|| crlf ||
        ' boundary="-----SECBOUND"'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'This is a test'|| crlf ||     -- Message body
        'of the email attachment'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/plain;'|| crlf ||
        ' name="ap_inv_supplier_cc10.txt"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="ap_inv_supplier_cc10.txt"'|| crlf ||
        crlf ||
        'TXT,file,attachment'|| crlf ||     -- Content of attachment  (THIS IS MY PROBLEM!  I NEED TO BE ABLE TO ATTACH AN EXISTING FILE, NOT CREATE A NEW ONE)
        crlf ||
        '-------SECBOUND--'               -- End MIME mail
      utl_smtp.Quit(v_mail_conn);
    EXCEPTION
      WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
        raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;
    /

    First, you must create a directory object
    create directory ORALOAD as '/home/ldcgroup/ldccbc/'
    /Study the Prerequisites in the link I posted above, or else you will not be able to read/write files from the above directory object
    "fname" relates to the file name that you read from.
    In the code below, it is also the name of the file that you are attaching.
    Although they can be different!
    l_Output is the contents of the file.
    declare
    vInHandle  utl_file.file_type;
    flen       number;
    bsize      number;
    ex         boolean;
    l_Output   raw(32767);
    fname      varchar2(30) := 'ap_inv_supplier_cc10.txt';
    vSender    varchar2(30) := '[email protected]';
    vRecip     varchar2(30) := '[email protected]';
    vSubj      varchar2(50) := 'Weekly Invoice Report';
    vAttach    varchar2(50) := 'ap_inv_supplier_cc10.txt';
    vMType     varchar2(30) := 'text/plain; charset=us-ascii';
    begin
      utl_file.fgetattr('ORALOAD', fname, ex, flen, bsize);
      vInHandle := utl_file.fopen('ORALOAD', fname, 'R');
      utl_file.get_raw (vInHandle, l_Output);
      utl_file.fclose(vInHandle);
      utl_mail.send_attach_raw(sender       => vSender
                              ,recipients   => vRecip
                              ,subject      => vsubj
                              ,attachment   => l_Output
                              ,att_inline   => false
                              ,att_filename => fname);
    end;
    /

  • Need to send email with excel sheet as attachment: URGENT

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

  • Sending mail with excel  more than 255 character in a line

    Dears,
    In my program , I use SO_NEW_DOCUMENT_ATT_SEND_API1  to send email with EXCEL attacment.
    But when i want output a line more than 255 characters  in the excel I met the problem, it only appeared 255 characters
    describe table mailbin lines tab_lines.
        mailpack-transf_bin = c_checked.
        mailpack-head_start = 1.
        mailpack-head_num = 1.
        mailpack-body_start = 1.
        mailpack-body_num = tab_lines.
        mailpack-doc_type = c_xls.
        mailpack-obj_name = space.
        mailpack-obj_descr = lv_mail_title. "the excel file name
        mailpack-doc_size = tab_lines * 255.
        append mailpack.
    * Sending the document
          call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
            exporting
              document_data              = maildata
              put_in_outbox              = space
              commit_work                = c_checked
            tables
              packing_list               = mailpack
              object_header              = mailhead
              contents_bin               = mailbin
              contents_txt               = mailtxt
              receivers                  = mailrec
            exceptions
              too_many_receivers         = 1
              document_not_sent          = 2
              operation_no_authorization = 4
              others                     = 99.
    But i have to output those characters in one line.
    Anyone could help me?
    Thanks a lot.
    Sincerely,
    Julie

    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,
            is_objbin  type  solisti1 .
    data: objtxt     like solisti1 occurs 10 with header line,
            is_objtxt  type solisti1 .
      data: l_tab(1)   type c value cl_abap_char_utilities=>horizontal_tab,
           con_cret   type c value cl_abap_char_utilities=>cr_lf.
    data: tab_lines  like sy-tabix,
            : tab_lines1 like sy-tabix.
      data : lenth_string type string,
            s_string     type string.
    data : L type i, i type i,cplen type i, balance type i,
    before describe table mailbin lines tab_lines ... Use below logic.
    Loop at your_internaltable.
    concatenate field_1
                field_2
                field_3
           into lenth_string separated by l_tab.
    concatenate  lenth_string con_cret into lenth_string.  
    concatenate s_string lenth_string into s_string.
    endloop.
           L = strlen( s_string ).
           i = 0.
           cplen = 255.
           balance = l.
        do.
          if balance <= 0.
            exit.
          endif.
          if balance < 255.
            cplen = balance.
          else.
            cplen = 255.
          endif.
          objbin = s_string+i(cplen).
          i = i + cplen.
          balance = balance - cplen.
          append objbin.
        enddo. 
    ...... after this use ur exesting code....describe table mailbin lines tab_lines and so
        describe table objbin lines tab_lines1.
        clear objpack-transf_bin.
        objpack-transf_bin = ' '.
        objpack-head_start = 1.
        objpack-head_num = 1.
        objpack-body_start = 1.
        objpack-body_num = tab_lines1.
        objpack-obj_langu = 'E'.
        objpack-doc_type = 'XLS'.
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        exporting
    -tables
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          receivers                  = reclist
    Regards,
    Sri.
    Edited by: sridhar arjunan on Jul 28, 2009 4:22 PM
    Edited by: sridhar arjunan on Jul 28, 2009 4:23 PM

  • Send email with 1 excel file and multiple sheet

    Hi,
    I need to send an email with attachment file in excel format.  The problem is now the requirement requires 2 worksheets/tabs in 1 excel file.
    For example: I need to put details data in sheet1 and summary data in sheet2 and this program should be working also if it is run in background mode.
    Currently, I’m using cl_document_bcs to create document, but could not find a way to create 2 tabs in the excel file.
    Has anyone got an ideas on how it should done?

    Hi,
    Welcome to SDN.
    check these links :
    /people/sap.user72/blog/2006/02/07/downloading-data-into-excel-with-format-options
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2a2dcd9e6c
    Regards
    Appana
    *reward Points for helpful answers

  • Urgent: Sending an Email with Excel sheet attachment

    Hi All,
    I am preparing a report and has to send mail with excel sheet attachement. In report i am getting everything fine. But in the mail i am not getting the data, data is passing to the FM succesfully. But in the mail, excel is not having full data.
    the below mentioned is my code.
    i_texts-line = c_stern.
      i_texts-line+254(1) = c_newline.
      APPEND i_texts.
      LOOP AT i_texc.
        i_att_line-line = i_texc.
        APPEND i_att_line.
      ENDLOOP.
      DATA: wa_doc_chng LIKE sodocchgi1.
      DATA: w_tab_lines LIKE sy-tabix.
      STATICS: c_body_start TYPE i VALUE '1'.
      CONSTANTS: lc_filename(10) TYPE c VALUE 'Attachment',
                 lc_atthead(30)  TYPE c VALUE 'Manually released invoices'.
      DATA: i_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: w_doc_name(30) TYPE c.
      DATA: l_text1(15),
            l_text2(12),
            l_text3(15),
            l_text4(15),
            l_text5(14),
            l_text6(17),
            l_text7(10),
            l_text8(20),
            l_text9(19),
            l_text10(19),
            l_text11(19),
            l_text12(16),
            l_text13(20),
            l_text14(19),
            l_text15(19),
            l_text16(30).
      DATA: DATE(10),
            DT(2),
            MON(3),
            YR(4),
            lc_final(50).
      CLEAR: i_texts, i_reci,i_att_line.                "i_bname,
      REFRESH: i_texts, i_reci,i_att_line.              "i_bname,
      WRITE sy-datum TO w_datex.
      WRITE sy-uzeit TO w_timex.
      l_text1 = text-003.
      l_text2 = text-004.
      l_text3 = text-005.
      l_text4 = text-006.
      l_text5 = text-007.
      l_text6 = text-008.
      l_text7 = text-009.
      l_text8 = text-010.
      l_text9 = text-011.
      l_text10 = text-012.
      l_text11 = text-013.
      l_text12 = text-014.
      l_text13 = text-015.
      l_text14 = text-016.
      l_text15 = text-017.
      l_text16 = text-026.
      CONCATENATE
      l_text1
      l_text2
      l_text3
      l_text4
      l_text5
      l_text6
      l_text7
      l_text8
      l_text9
      l_text10
      l_text11
      l_text12
      l_text13
      l_text14
      l_text15
      l_text16
      INTO i_texts SEPARATED BY
      c_horz_tab.
      i_texts-line+254(1) = c_newline.
      APPEND i_texts.
      CLEAR  i_texts.
      LOOP AT i_texc.
        i_att_line-line = i_texc.
        APPEND i_att_line.
      ENDLOOP.
      LOOP AT so_rec.
        i_reci-receiver = so_rec-low.
        i_reci-express = 'X'.
        i_reci-rec_type = 'U'.
        APPEND i_reci.
      ENDLOOP.
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      READ TABLE i_texts INDEX w_tab_lines.
      wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
      wa_obj_name   = 'ZFI_XX_REL_BLOCKED_INVOICE_01'.
      DT  = SY-DATUM+6(2).
      MON = SY-DATUM+4(2).
      YR  = SY-DATUM+0(4).
      CONCATENATE DT MON YR INTO DATE SEPARATED BY '-'.
      CONCATENATE lc_atthead date into lc_final separated by ' '.
      MOVE lc_final
                   TO wa_obj_descr .
      wa_doc_chng-obj_name  = wa_obj_name.
      wa_doc_chng-obj_descr = wa_obj_descr.
      CLEAR i_objpack-transf_bin.
      i_objpack-head_start = 1.
      i_objpack-head_num = 0.
      i_objpack-body_start = 0.
      i_objpack-body_num = w_tab_lines.
      i_objpack-doc_type = 'RAW'.
      APPEND i_objpack.
      APPEND LINES OF i_att_line TO i_texts.
      LOOP AT i_arseg INTO wa_arseg.
        i_xmplt_d-belnr = wa_arseg-belnr.
        i_xmplt_d-budat = wa_arseg-budat.
        i_xmplt_d-bukrs = wa_arseg-bukrs.
        i_xmplt_d-lifnr = wa_arseg-lifnr.
        i_xmplt_d-name1_lifnr = wa_arseg-name1_lifnr.
        i_xmplt_d-wrbtr = wa_arseg-wrbtr.
        i_xmplt_d-waers = wa_arseg-waers.
        i_xmplt_d-ebeln = wa_arseg-ebeln.
        i_xmplt_d-ebelp =  wa_arseg-ebelp.
        i_xmplt_d-reason = wa_arseg-reason.
        i_xmplt_d-dmeng = wa_arseg-dmeng.
        i_xmplt_d-dwert = wa_arseg-dwert.
        i_xmplt_d-bname = wa_arseg-bname.
        i_xmplt_d-name_text = wa_arseg-name_text.
        i_xmplt_d-udate = wa_arseg-udate.
        i_xmplt_d-comment =  wa_arseg-comment.
        APPEND i_xmplt_d.
      ENDLOOP.
      LOOP AT i_xmplt_d.
        CONCATENATE i_xmplt_d-belnr
                    i_xmplt_d-budat
                    i_xmplt_d-bukrs
                    i_xmplt_d-lifnr
                    i_xmplt_d-name1_lifnr
                    i_xmplt_d-wrbtr
                    i_xmplt_d-waers
                    i_xmplt_d-ebeln
                    i_xmplt_d-ebelp
                    i_xmplt_d-reason
                    i_xmplt_d-dmeng
                    i_xmplt_d-dwert
                    i_xmplt_d-bname
                    i_xmplt_d-name_text
                    i_xmplt_d-udate
                    i_xmplt_d-comment
                    INTO i_texts SEPARATED
                    BY c_horz_tab.
        i_texts-line+254(1) = c_newline.
        APPEND i_texts.
        CLEAR i_texts.
      ENDLOOP.
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      READ TABLE i_texts INDEX w_tab_lines.
      wa_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( i_texts ).
      DESCRIBE TABLE i_texts LINES w_tab_lines.
      i_objpack-transf_bin = ' '.
      i_objpack-head_start = 0.
      i_objpack-head_num = 0.
      i_objpack-body_start = 1.
      i_objpack-body_num = w_tab_lines.
      i_objpack-doc_type = 'XLS'.
      i_objpack-obj_name = 'Attachment'.
    i_objpack-obj_descr = w_doc_name.
      i_objpack-obj_descr = lc_filename.
      i_objpack-doc_size = w_tab_lines * 255.
      APPEND i_objpack.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
        TABLES
          packing_list               = i_objpack
          contents_txt               = i_texts
          receivers                  = i_reci
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc = 0.
        COMMIT WORK.
      ELSE.
        WRITE: / 'Error in send E-Mail' .
      ENDIF.
    please revert me asap. It is very urgent to me. thanks in advance.
    Bye

    hI
    Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
    * End of Selection Event : Displaying the selected data                *
    END-OF-SELECTION.
        PERFORM EMAIL_EXCEL_ATTACHMENT.
    ******///form
    FORM EMAIL_EXCEL_ATTACHMENT .
    * Populate table with detaisl to be entered into .xls file
      PERFORM BUILD_XLS_DATA_TABLE.
    * 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 S_EMAIL
                                          TEXT-042
                                          C_XLS
                                          'filename'
                                 CHANGING GD_ERROR
                                          GD_RECIEVER.
    *   Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
    ENDFORM.                    " EMAIL_EXCEL_ATTACHMENT
    ********///form BUILD_XLS_DATA_TABLE
    FORM BUILD_XLS_DATA_TABLE .
      DATA :    LV_NETWR(20)     TYPE C,
                LV_BOL_DATE(20)  TYPE C,
                LV_KAWRT(20)     TYPE C,
                LV_FKDAT(20)     TYPE C,
                LV_WAERK(20)     TYPE C,
                LV_KURRF(20)     TYPE C,
                LV_SHIPDATE(20)  TYPE C,
                LV_DEPTDATE(20)  TYPE C.
      CONSTANTS:
          CON_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
          CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.  "#EC *
      DATA STR TYPE STRING.
    **********/ this parameter concatenate to get headers
      CONCATENATE STR
      'SLNO'
      'OWNER'
      'SERIAL NO'
      'FROM'
      'DESTINATION'
      'INVOICE VALUE'
      'DESCRIPTION'
      'CUSTOMER NAME'
      'BL NUMBER'
      'BL DATE'
      'VESSEL NAME/AIRLINE DETAILS'
      'MODE OF TRANSIT'
      'SHIPPING MARKS'
      'DUTY SUM INSURED'
      'FLAG'
      'OPEN COVERNO'
      'INVOICE DATE'
      'INVOICE NO'
      'LC WORDING'
      'QUANTITY'
      'PACKAGING DETAILS'
      'BASIS OF VALUATION'
      'EXCLUDE WAR SRCC'
      'CURRENCY'
      'EXCHANGE RATE'
      'ADDRESS'
      'VESSEL BUILT YEAR'
      'VESSEL FLAG'
      'VOYAGE NO'
      'SHIPMENT DATE'
      'DEPARTURE DATE'
      'SURVEYOR COUNTRY'
      'SURVEYOR CITY'
      'SURVEYOR AGENT'
      'SURVEYOR ADDRESS'
      'EXPORT CONSIGNMENT'
      'CONTAINER DETAILS'
      CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
      LOOP AT IT_FINAL.
    *******/ this is to pass body / row data
        WRITE : IT_FINAL-NETWR    TO LV_NETWR,              "#EC UOM_IN_MES
                IT_FINAL-BOL_DATE TO LV_BOL_DATE,
                IT_FINAL-KAWRT    TO LV_KAWRT,              "#EC UOM_IN_MES
                IT_FINAL-FKDAT    TO LV_FKDAT,
                IT_FINAL-WAERK    TO LV_WAERK,
                IT_FINAL-KURRF    TO LV_KURRF,
                IT_FINAL-SHIPDATE TO LV_SHIPDATE,
                IT_FINAL-DEPTDATE TO LV_DEPTDATE.
        CONCATENATE
               STR
               IT_FINAL-SLNO
               IT_FINAL-OWNER
               IT_FINAL-SRNO
               IT_FINAL-PORT_LOAD
               IT_FINAL-PORT_DSCHR
               LV_NETWR
               IT_FINAL-DESCRIP
               IT_FINAL-CUSTNAME
               IT_FINAL-BOL_NUM
               LV_BOL_DATE
               IT_FINAL-VESSELNAME
               IT_FINAL-SHP_TYPE
               IT_FINAL-SHP_MARK
               LV_KAWRT
               IT_FINAL-FLAG
               IT_FINAL-OPEN_CONO
               LV_FKDAT
               IT_FINAL-VBELN
               IT_FINAL-LC_WORD
               IT_FINAL-QUANT
               IT_FINAL-PACKDETL
               IT_FINAL-INCO1
               IT_FINAL-EXCWSR
               LV_WAERK
               LV_KURRF
               IT_FINAL-ADDPAY
               IT_FINAL-VESSBYR
               IT_FINAL-VESSFLG
               IT_FINAL-VOY_FLY_NO
               LV_SHIPDATE
               LV_DEPTDATE
               IT_FINAL-SURCOUNT
               IT_FINAL-INCO2
               IT_FINAL-EXPORT_CON
               IT_FINAL-SURAGT
               IT_FINAL-SURADD
               IT_FINAL-CONTRNO
       CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
      ENDLOOP.
      CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
        EXPORTING
          TEXT      = STR
        TABLES
          FTEXT_TAB = IT_ATTACH.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    ******// form POPULATE_EMAIL_MESSAGE_BODY
    FORM POPULATE_EMAIL_MESSAGE_BODY .
      REFRESH IT_MESSAGE.
      IT_MESSAGE = TEXT-043.  " Please find attached Insurance Certificate details
      APPEND IT_MESSAGE.
    ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
    *******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       text
    *      -->PIT_MESSAGE           text
    *      -->PIT_ATTACH            text
    *      -->P_EMAIL               text
    *      -->P_MTITLE              text
    *      -->P_FORMAT              text
    *      -->P_FILENAME            text
    *      -->P_ATTDESCRIPTION      text
    *      -->P_SENDER_ADDRESS      text
    *      -->P_SENDER_ADDRES_TYPE  text
    *      -->P_ERROR               text
    *      -->P_RECIEVER            text
    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.       "#EC *
      DATA: LD_ERROR    TYPE SY-SUBRC,                          "#EC *
    *        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.                         "#EC *
    *  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.
      DESCRIBE TABLE IT_ATTACH LINES W_CNT.
      READ TABLE IT_ATTACH INDEX W_CNT.
      W_DOC_DATA-DOC_SIZE =
         W_CNT * 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.
      LOOP AT S_EMAIL.
        T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
        T_RECEIVERS-REC_TYPE = 'U'.
        T_RECEIVERS-COM_TYPE = 'INT'.
        T_RECEIVERS-NOTIF_DEL = 'X'.
        T_RECEIVERS-NOTIF_NDEL = 'X'.
        APPEND T_RECEIVERS.
      ENDLOOP.
      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.                    " SEND_FILE_AS_EMAIL_ATTACHMENT
    *******/form
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       text
    *  -->  p1        text
    *  <--  p2        text
    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
    *********end of code to trigger mail in excel format....
    If any other help please let me know......
    I am sure this example code will help you to resolve your problem...
    please analyse above code for your requirement...
    In my scenario the message you said is not displaying.....
    Reward Points

Maybe you are looking for

  • HDMI cable and wireless router for bluray

    Hi. We just purchased a Samsung Blu-ray player, model BD-C 6500. We want to connect it to our 46" samsung LED TV  and stream movies from Netflix.  I was wondering which HDMI cable would be best to use to connect it? We also havea Netgear Rangemax rou

  • Creating Photo Album

    I've tried creating a photoalbum through Dreamweaver 8 and Fireworks 6. When I click to create album, Photoshop automatically opens and I get message saying unable to create -- Photoshop doesn't recognize file type (I've tried using .jpg and .png). I

  • How to change OS X Lion (10.7) login background

    I just installed OS X Lion (10.7).  I would like to change the login background on my iMac.  The gray linen is too plain and boring. Does anyone know a sure-fire way to change the login background? My google search showed how to do this in Snow Leopa

  • Question about issues with display - MacBook Pro.

    So, recently, my cat jumped onto the keyboard while I was working. Ever since, I have been unable to get the display sized to fit into the screen. Even when I got to the display menu and alter the resolution, the image remains stretched. I have to pu

  • RMAN configuration parameters for Oracle8i

    HELP - i'm migrating a production database from one server to another and need the current RMAN configuation parameters on the original database in order to migrate these same parameters to the target database. Could anyone ghelp me figuring out the