Excel file as attachment in mail

Hi Friends,
I have a requirement of sending th Excel sheet through email attachment.
I am getting the records into the internal table,but after sending the Email and receiving it the first line in the excel sheet is a blank line.
Can you please provide me a solution with source code.

Hi Pooja,
check thios code...hope it helps
*& Report ZWBSAP_EMAIL *
*Send an email via SAP Workplace
*Select files from SAP server
*Note:
Uses custom table zlookup to pick up a group of email addresses to send to
if more than one is needed.
Please note some hard coding.
REPORT zsap_email MESSAGE-ID z001.
TABLES: rlgrap, btcxpm, zlookup.
DATA:
v_zcode(3) TYPE c,
svrname LIKE zlookup-zdesc,
wa_error(80) TYPE c,
global_filemask_all(80).
DATA: t_soud LIKE soud.
DATA: p_infolder LIKE sofdk.
DATA: p_outfolder LIKE sofdk.
DATA: object_hd_display LIKE sood2.
DATA: object_id LIKE soodk.
DATA: document LIKE sood4.
DATA: header_data LIKE sood2.
DATA: link_folder_id LIKE soodk.
DATA: folder_selections LIKE sofds.
DATA: folder_list LIKE soxli OCCURS 0 WITH HEADER LINE.
DATA: receivers LIKE soos1 OCCURS 0 WITH HEADER LINE.
DATA: objcont LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: objhead LIKE soli OCCURS 0 WITH HEADER LINE.
DATA: object_content LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: object_hd_change LIKE sood1.
DATA: BEGIN OF files OCCURS 0,
line(200) TYPE c,
END OF files.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
*Email to addresses
SELECTION-SCREEN: BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
PARAMETERS: p_mailto(240) TYPE c.
SELECTION-SCREEN SKIP 1.
SELECTION-SCREEN COMMENT 10(2) text-001.
*Use zlookup-ztype as group to define multiple email to addresses
SELECT-OPTIONS: s_mailto FOR zlookup-ztype.
SELECTION-SCREEN: END OF BLOCK bl1.
*Subject
SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-bl2.
PARAMETERS: p_subj LIKE document-objdes.
SELECTION-SCREEN: END OF BLOCK bl2.
*Body
SELECTION-SCREEN: BEGIN OF BLOCK bl3 WITH FRAME TITLE text-bl3.
PARAMETERS: p_body1 LIKE solisti1-line LOWER CASE.
PARAMETERS: p_body2 LIKE solisti1-line LOWER CASE.
PARAMETERS: p_body3 LIKE solisti1-line LOWER CASE.
PARAMETERS: p_body4 LIKE solisti1-line LOWER CASE.
PARAMETERS: p_body5 LIKE solisti1-line LOWER CASE.
PARAMETERS: p_body6 LIKE solisti1-line LOWER CASE.
SELECTION-SCREEN: END OF BLOCK bl3.
*Attachments
SELECTION-SCREEN: BEGIN OF BLOCK bl4 WITH FRAME TITLE text-bl4.
PARAMETERS: p_fname1 LIKE files-line.
PARAMETERS: p_fname2 LIKE files-line.
PARAMETERS: p_fname3 LIKE files-line.
PARAMETERS: p_fname4 LIKE files-line.
PARAMETERS: p_fname5 LIKE files-line.
PARAMETERS: p_fname6 LIKE files-line.
SELECTION-SCREEN: END OF BLOCK bl4.
AT SELECTION-SCREEN.
PERFORM chk_selection.
IF NOT wa_error IS INITIAL.
MESSAGE e001 WITH wa_error.
ENDIF.
START-OF-SELECTION.
END-OF-SELECTION.
PERFORM send_email.
FORM chk_selection *
FORM chk_selection.
CLEAR wa_error.
*Loop only once ???
*If more checkings to be done.
*Think about it and if not clear.
*Let it sink in for a couple of minutes.
*Still doesn't make sence? Go home and sleep on it.
DO 1 TIMES.
*Check Email to
IF p_mailto IS INITIAL
AND s_mailto IS INITIAL.
wa_error = 'Invalid or no EMAIL TO selection'.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
*& Form send_email
text
--> p1 text
<-- p2 text
FORM send_email.
PERFORM get_folder_info.
PERFORM fill_body.
PERFORM ins_new_object.
PERFORM crt_attachments.
PERFORM fill_receivers_info.
PERFORM snd_email.
ENDFORM. " send_email
FORM Get_folder_info *
FORM get_folder_info.
CLEAR t_soud.
*Small so should be quick.
SELECT * FROM soud
INTO t_soud
WHERE sapnam = sy-uname.
p_infolder-foltp = 'FOL'.
p_infolder-folyr = t_soud-inbyr. "inbox
p_infolder-folno = t_soud-inbno.
p_outfolder-foltp = 'FOL'.
p_outfolder-folyr = t_soud-outyr. "outbox
p_outfolder-folno = t_soud-outno.
ENDSELECT.
ENDFORM.
FORM fill_body *
FORM fill_body.
object_content-line = p_body1.
APPEND object_content.
object_content-line = p_body2.
APPEND object_content.
object_content-line = p_body3.
APPEND object_content.
object_content-line = p_body4.
APPEND object_content.
object_content-line = p_body5.
APPEND object_content.
object_content-line = p_body6.
APPEND object_content.
ENDFORM.
FORM ins_new_object *
FORM ins_new_object.
object_hd_change-objnam = 'Notes'.
object_hd_change-objdes = p_subj.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = p_outfolder
object_hd_change = object_hd_change
object_type = 'RAW'
owner = sy-uname
IMPORTING
object_hd_display = object_hd_display
object_id = object_id
TABLES
objcont = object_content
objhead = objhead
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
dl_name_exist = 4
folder_not_exist = 5
folder_no_authorization = 6
object_type_not_exist = 7
operation_no_authorization = 8
owner_not_exist = 9
parameter_error = 10
substitute_not_active = 11
substitute_not_defined = 12
system_failure = 13
x_error = 14
OTHERS = 15.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
FORM crt_attachments *
--> P_SUBJ *
FORM crt_attachments.
document-foltp = p_outfolder-foltp.
document-folyr = p_outfolder-folyr.
document-folno = p_outfolder-folno.
document-objtp = object_id-objtp.
document-objyr = object_id-objyr.
document-objno = object_id-objno.
document-objnam = 'Notes'.
document-objdes = p_subj.
document-okcode = 'CHNG'.
document-file_ext = 'TXT'.
link_folder_id = object_id.
header_data-objla = 'EN'.
header_data-objnam = document-objnam.
header_data-objdes = document-objdes.
header_data-objpri = '5'.
header_data-objsns = 'O'.
header_data-file_ext = 'TXT'.
REFRESH files.
CLEAR files.
IF NOT p_fname1 IS INITIAL.
files-line = p_fname1.
APPEND files.
ENDIF.
IF NOT p_fname2 IS INITIAL.
files-line = p_fname2.
APPEND files.
ENDIF.
IF NOT p_fname3 IS INITIAL.
files-line = p_fname3.
APPEND files.
ENDIF.
IF NOT p_fname4 IS INITIAL.
files-line = p_fname4.
APPEND files.
ENDIF.
IF NOT p_fname5 IS INITIAL.
files-line = p_fname5.
APPEND files.
ENDIF.
IF NOT p_fname6 IS INITIAL.
files-line = p_fname6.
APPEND files.
ENDIF.
IF NOT files[] IS INITIAL.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'ATTCREATEFROMPC'
TABLES
files = files
CHANGING
document = document
header_data = header_data.
IF sy-subrc = 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM.
FORM fill_receivers_info *
FORM fill_receivers_info.
DATA: BEGIN OF reclist OCCURS 0,
rec LIKE receivers-recextnam,
END OF reclist.
*Build reclist
REFRESH reclist.
IF NOT p_mailto IS INITIAL.
reclist-rec = p_mailto.
APPEND reclist.
ENDIF.
IF NOT s_mailto IS INITIAL.
SELECT zdesc
INTO reclist-rec
FROM zlookup
WHERE ztype IN s_mailto.
APPEND reclist.
ENDSELECT.
ENDIF.
REFRESH receivers.
LOOP AT reclist.
folder_selections-folnam = 'INBOX'.
CALL FUNCTION 'SO_FOLDER_LIST_READ'
EXPORTING
folder_selections = folder_selections
owner = sy-uname
region = 'P'
TABLES
folder_list = folder_list
EXCEPTIONS
component_not_available = 1
operation_no_authorization = 2
owner_not_exist = 3
parameter_error = 4
x_error = 5
OTHERS = 6.
IF sy-subrc = 0.
CLEAR receivers.
receivers-rcdat = sy-datum.
receivers-rctim = sy-uzeit.
receivers-recnam = reclist-rec.
receivers-recno = folder_list-parno.
receivers-rectp = folder_list-partp.
receivers-recyr = folder_list-paryr.
receivers-sndtp = folder_list-partp.
receivers-sndyr = folder_list-paryr.
receivers-sndno = folder_list-parno.
receivers-sndnam = sy-uname.
receivers-sndpri = '1'.
receivers-msgid = 'SO'.
receivers-msgno = '619'.
receivers-deliver = 'X'.
receivers-not_deli = 'X'.
receivers-read = 'X'.
receivers-mailstatus = 'E'.
*receivers-ADR_NAME
receivers-resend = ' '.
receivers-sortfield = ' '. "'USER WF_BATCH INDIGO BATCH'.
receivers-sortclass = '5'.
APPEND receivers.
ELSE.
CLEAR receivers.
receivers-sel = 'X'.
receivers-recesc = 'U'.
receivers-recnam = 'U-'.
receivers-recextnam = reclist-rec.
receivers-deliver = 'X'.
receivers-not_deli = 'X'.
receivers-read = 'X'.
receivers-mailstatus = 'E'.
receivers-adr_name = reclist-rec.
receivers-sortfield = reclist-rec.
receivers-sortclass = '5'.
APPEND receivers.
ENDIF.
ENDLOOP.
ENDFORM.
FORM snd_email *
FORM snd_email.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
folder_id = p_outfolder
object_id = object_id
outbox_flag = 'X'
owner = sy-uname
check_send_authority = 'X'
originator_type = 'J'
link_folder_id = link_folder_id
TABLES
objcont = object_content
receivers = receivers
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
originator_not_exist = 20
x_error = 21
OTHERS = 22.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
Thanks
Nayan

Similar Messages

  • How to send other language data into excel file in attachment thru mail

    Hi - ,
    I have to send other language data (russian) into excel file and send as an attachment through e-mail.
    I had used F.M SO_NEW_DOCUMENT_ATT_SEND_API1 to send email.
    In internal table , it is in correct format, but when using SO_NEW_DOCUMENT_ATT_SEND_API1, the excel file sent has junk characters in it.
    Can u please help me on this?
    Thanks,
    Gyanaraj

    Hi ,
    Can anyone help me on this.
    Thanks,
    Gyanaraj

  • Sending a excel sheet as attachment in mail

    Hi,
    I have requirement where I need to send excel sheet as attachment in mail. I could do it by using FM SO_NEW_DOCUMENT_ATT_SEND_API1. But, I am not able to format the excel sheet before sending.
    I need to make heading bold, fix column width and wrap text in some cells, and send the mail.
    Pls help me with your suggestions.
    Thanks,
    Siva.

    this link will show you how to do formatting in Excel using the OLE method, then use that EXCEL to send the MAIL using your program \
    [OLE-format excel |http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm]
    Hope That Helps
    Anirban M.

  • Read multi-tabbed excel file attachments from Sender Mail Adapter.

    There is a need to read excel attachments from incoming email to a
    mailbox. We know we can use Sender Mail adapter to easily read .xml, .txt
    or .csv attachments.
    For excel attachments we know from SDN that you have to write
    adapter modules to handle excel. However the excel file we need to read has
    multiple worksheets(tabs) and data may be contained in any of them.
    Is it possible to use SAP XI Mailsender adapter to read such a file as an attachment? What kind of module development would we need for this? I am not much of a Java programmer so examples or links to other documentation would help.
    Thanks,
    Rudra

    Rudra,
    Use Java Mapping.  There is a free java api available called JExcelAPI to achieve this. 
    Shabarish's blog describes about this.  This might be helpful to you
    /people/shabarish.vijayakumar/blog/2009/04/05/excel-files--how-to-handle-them-in-sap-xipi-the-alternatives

  • Passing data to excel file and sending as mail

    Hello Everyone,
    I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send an excel file as an attachment to a mail id.
    But the issue is i have 4 fields in excel vendor, material, material descp and PO number.
    The vendor field is of char 10 i need to show all the leading zeros in the excel file.
    I.e  now i am getting vendor as 88058 in the excel file but i need to show it as 0000088058.
    If anyone has come across such issue please provide some solution to it.
    Thanks & Regards,
    Ravi Aswani

    Hi,
    This is the code snippet I have used to generate the test file.
    REPORT  ztest_download.
    TYPES: BEGIN OF ty_data,      
    vbeln TYPE vbeln,      
    amt   TYPE dmbtr,      
    long  TYPE char30,      
    text  TYPE char20,      
    END   OF ty_data.
    DATA: it_data TYPE STANDARD TABLE OF ty_data,      wa_data TYPE ty_data.
    START-OF-SELECTION.
      DO 5 TIMES.    wa_data-vbeln = sy-index.   
    UNPACK wa_data-vbeln TO wa_data-vbeln.   
    wa_data-amt   = '12345.67' * sy-index.   
    wa_data-long  = '12345678901234567890'.   
    wa_data-text  = sy-abcde.   
    APPEND wa_data TO it_data.   
    CLEAR  wa_data. 
    ENDDO.
    DATA: l_file TYPE string.
    here we will pass the .txt instead of the .xls*
    l_file = 'C:\temp\test_data.txt'.
    In the Filetype, we still pass the DAT because we want* our output in the tabular format. 
    CALL FUNCTION 'GUI_DOWNLOAD'   
    EXPORTING    
    filename                = l_file     
    filetype                = 'DAT'  
    TABLES     
    data_tab                = it_data   
    EXCEPTIONS     
    file_write_error        = 1     
    no_batch                = 2     
    gui_refuse_filetransfer = 3     
    invalid_type            = 4    
    no_authority            = 5     
    unknown_error           = 6     
    header_not_allowed      = 7    
    separator_not_allowed   = 8     
    filesize_not_allowed    = 9     
    header_too_long         = 10     
    dp_error_create         = 11     
    dp_error_send           = 12     
    dp_error_write          = 13     
    unknown_dp_error        = 14     
    access_denied           = 15     
    dp_out_of_memory        = 16     
    disk_full               = 17     
    dp_timeout              = 18     
    file_not_found          = 19     
    dataprovider_exception  = 20     
    control_flush_error     = 21.
    Moderator message: copy/paste without credit, do not repeat!
    http://www.google.com/search?hl=en&q=%22ThisisthecodesnippetIhaveusedtogeneratethetestfile%22
    Edited by: Thomas Zloch on Oct 15, 2010 4:27 PM

  • Send email with existing excel-file as attachment

    Is there a function to send an e-mail with an attachment which is an existing excel-file on my C:\-drive.
    I found lots of possibilities to send mail with internal tables as attachment but in my case the attachment is an existing excel-file (c:\test.xls)...
    thanx

    Hi,
    FOund these function modules
    Try this out.
    ISR_FI_SEND_EMAIL             
    ISR_FI_SEND_EMAIL_NEW_USER    
    SLS_CUST_SEND_EMAIL_TOOL      
    OR
    report y_cr17_mail.
    data method1 like sy-ucomm.
    data g_user like soudnamei1.
    data g_user_data like soudatai1.
    data g_owner like soud-usrnam.
    data g_receipients like soos1 occurs 0 with header line.
    data g_document like sood4 .
    data g_header like sood2.
    data g_folmam like sofm2.
    data g_objcnt like soli occurs 0 with header line.
    data g_objhead like soli occurs 0 with header line.
    data g_objpara  like selc occurs 0 with header line.
    data g_objparb  like soop1 occurs 0 with header line.
    data g_attachments like sood5 occurs 0 with header line.
    data g_references like soxrl occurs 0 with header line.
    data g_authority like sofa-usracc.
    data g_ref_document like sood4.
    data g_new_parent like soodk.
    data: begin of g_files occurs 10 ,
      text(4096) type c,
       end of g_files.
    data : fold_number(12) type c,
           fold_yr(2) type c,
           fold_type(3) type c.
    parameters ws_file(4096) type c default 'c:\debugger.txt'.
    Can me any file fromyour pc ....either xls or word or ppt etc ...
    g_user-sapname = sy-uname.
    call function 'SO_USER_READ_API1'
    exporting
       user                            = g_user
       PREPARE_FOR_FOLDER_ACCESS       = ' '
    importing
       user_data                       = g_user_data
    EXCEPTIONS
       USER_NOT_EXIST                  = 1
       PARAMETER_ERROR                 = 2
       X_ERROR                         = 3
       OTHERS                          = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    fold_type = g_user_data-outboxfol+0(3).
    fold_yr = g_user_data-outboxfol+3(2).
    fold_number =  g_user_data-outboxfol+5(12).
    clear g_files.
    refresh : g_objcnt,
      g_objhead,
      g_objpara,
      g_objparb,
      g_receipients,
      g_attachments,
      g_references,
      g_files.
    method1 = 'SAVE'.
    g_document-foltp  = fold_type.
    g_document-folyr   = fold_yr.
    g_document-folno   = fold_number.
    g_document-objtp   = g_user_data-object_typ.
    *g_document-OBJYR   = '27'.
    *g_document-OBJNO   = '000000002365'.
    *g_document-OBJNAM = 'MESSAGE'.
    g_document-objdes   = 'sap-img.com testing by program'.
    g_document-folrg   = 'O'.
    *g_document-okcode   = 'CHNG'.
    g_document-objlen = '0'.
    g_document-file_ext = 'TXT'.
    g_header-objdes =  'sap-img.com testing by program'.
    g_header-file_ext = 'TXT'.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = sy-uname
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
      FOLMEM_DATA        =
      RECEIVE_DATA       =
    File from the pc to send...
    method1 = 'ATTCREATEFROMPC'.
    g_files-text = ws_file.
    append g_files.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header
    method1 = 'SEND'.
    g_receipients-recnam = 'MK085'.
    g_receipients-recesc = 'B'.
    g_receipients-sndex = 'X'.
    append  g_receipients.
    call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
      exporting
        method             = method1
       office_user        = g_owner
       ref_document       = g_ref_document
       new_parent         =  g_new_parent
    importing
       authority          =  g_authority
    tables
       objcont            = g_objcnt
       objhead            = g_objhead
       objpara            = g_objpara
       objparb            = g_objparb
       recipients         = g_receipients
       attachments        = g_attachments
       references         = g_references
       files              = g_files
      changing
        document           = g_document
       header_data        = g_header.
    *-- End of Program
    Thanks & Regards,
    Judith.

  • Sending File as attachment using Mail adapter with naming convention

    Dear All,
    I am working on a scenario in which my sender file adapter is sending one file named 'ABC.ok' in one of the folders in application server. I have to send the same file with the same name  to one of the folders at FTP and also to my customer at his email id.
    I have used File Content onversion at the receiver side and has selected adapter specific attributes due to which the required file is getting generated at FTP folder with the same name as that of the source. But how to send the same file using the mail adapter by keeping same name as "ABC.ok". Kindly guide me out in this.
    Regards,
    NJ

    what you need to do:
    1) Select ASMA in Sender and receiver File CC...already done
    2) Using the Dynamic Config UDF get the sender file name in the field Content-Type...for this you need to have a return statement in your UDF
    3) now before pushing this file name to the Content-Type you have to append (concat)the actual type of the file content (xml, txt)
    so your entire Content-Type node will have something like text/plain; name="abc.ok"
    SAP Note has reference on how to do this:
    https://service.sap.com/sap/support/notes/856599
    From the note:
    Q: How can I set the file name of a mail attachment?
    Regards,
    Abhishek.

  • Send Excel File as attachment

    I need to send an Excel file created by a query written in PL/SQL by email (Oracle 8). What is the process and steps to do this?

    I need to send an Excel file created by a query written in PL/SQL by email (Oracle 8). What is the process and steps to do this?

  • Help needed saving excel file using servlet and mailing it as attachment

    Hi,
    I have to enhance an existing application in which (in jsp) using response.setContentType("application/vnd.ms-excel");
    response.setHeader("Content-Disposition", "attachment=inline");
    and stuff ..
    we are asking user to view or save the file. But now i have to write code to save that xls, and send it as an attachment to other users of the application.
    I am new to this plz help me out
    Thanks in advance
    Regards
    Aashi

    Hi Orlando,
    convert content to Hex format then,
    lw_document = cl_document_bcs=>create_document(
               i_type    = 'RAW / HTM'
               i_text    = lw_main_text
               i_subject = lw_subject ).
          w_document->add_attachment(
             i_attachment_type    = 'XLS'
             i_attachment_subject = lw_att_sub
             i_att_content_text   = p_int_soli[]
             i_att_content_hex    = p_int_solix[] ).
    w_int_address = lw_smtp-low.
                 w_camuser = cl_cam_address_bcs=>create_internet_address( w_int_address ).
                 w_recipient = w_camuser.
    thanks,
    Anil

  • Error while sending excel sheet as attachment to Mail Receiver

    Hi everyone,
    I am facing the below error when I am trying to send data to Mail receiver adapter. The attachment is excel sheet.
    Delivery of the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Object not found in lookup of MessageTransformBean.: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of MessageTransformBean..
    I don't understand where the problem is. This has been running since long time and last month we have changed our web dispatcher details. I hope everything is fine. But not sure the root cause for this issue.
    Please help me in resolving this.
    Thank you.
    Regards
    Bhanu T.

    Check if this helps: MessageTransformBean module
    Confirm that you have configured the MessagetransformationBean properly.
    Are you trying to convert some payload into Excel and send it as an attachment in the Mail CC? If yes, then I hope that you have included the correct Content_type value.
    Check this for more info on Content_type: /people/community.user/blog/2006/09/08/email-report-as-attachment-excelword
    Regards,
    Abhishek.

  • Send XML File as attachement in Mail Receiver adapter

    Hi all,
    i have the following scenario. i would like to read an XML file from the file system and send this file as an attachement of a mail to a mail receiver specified in this file.
    i would like to fill the payload of the mail with some information from the xml file and in addition i would like to send the complete xml file as an mail attachement.
    can anybody tell me, how the mail receiver adater needs to be specified ?
    best regards,
    martin

    Hey,
    you can go for dynamic configuration of mail adapter.
    In this you need to import a mail structure.
    mail details such as to, from, subject and content of the mail are a part of the structure.
    In your ID check the Use Mail package and also keep attachments.
    Now you can give your details in mapping itself.
    whatever you want to map in the content of the mail, map it in the content field.
    also your file will behave as an attachment.
    refer to this blog.
    this is the mail structure. Import it as extenal definitions.
    <?xml version="1.0" encoding="utf-8" ?>
    <!--
    SAP takes no position regarding the validity or scope of any intellectual property or
    other rights that might be claimed to pertain to the implementation or use of the
    technology described in this document or the extent to which any license under such
    rights might or might not be available; neither does it represent that it has made any
    effort to identify any such rights.
    Copyright © SAP 2003-2004. All Rights Reserved.
    This document and translations of it may be copied and furnished to others, and derivative
    works that comment on or otherwise explain it or assist in its implementation may be
    prepared, copied, published and distributed, in whole or in part, without restriction of
    any kind, provided that the above copyright notice and this paragraph are included on all
    such copies and derivative works. However, this document itself does not be modified in
    any way, such as by removing the copyright notice or references to SAP.
    This document and the information contained herein is provided on an u201CAS ISu201D
    basis and SAP DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
    ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
    IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
    -->
    <xs:schema targetNamespace="http://sap.com/xi/XI/Mail/30"
      xmlns:xi="http://sap.com/xi/XI/Mail/30"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!--
    Mail
      -->
      <xs:element name="Mail">
        <xs:annotation>
          <xs:documentation>Mail package for XI - Mail Adapter</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Subject" type="xs:string" minOccurs="0"/>
            <xs:element name="From" type="xs:string" minOccurs="0"/>
            <xs:element name="To" type="xs:string" minOccurs="0"/>
            <xs:element name="Reply_To" type="xs:string" minOccurs="0"/>
            <xs:element name="Content_Type" type="xs:string" minOccurs="0"/>
            <xs:element name="Date" type="xs:dateTime" minOccurs="0"/>
            <xs:element name="Message_ID" type="xs:string" minOccurs="0"/>
            <xs:element name="X_Mailer" type="xs:string" minOccurs="0"/>
            <xs:element name="Content" minOccurs="0">
              <xs:annotation>
                <xs:documentation>any type</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="encoding" type="xs:string"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="MailReceipt">
        <xs:annotation>
          <xs:documentation>Mail Receipt for XI - Mail Adaper</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Server" type="xs:string"/>
            <xs:element name="Format" type="xs:string"/>
            <xs:element name="UseMailPackage" type="xs:boolean"/>
            <xs:element name="Encoding" type="xs:string"/>
            <xs:element name="Subject" type="xs:string" minOccurs="0"/>
            <xs:element name="From" type="xs:dateTime" minOccurs="0"/>
            <xs:element name="To" type="xs:string" minOccurs="0"/>
            <xs:element name="Date" type="xs:dateTime" minOccurs="0"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    regards,
    milan

  • Dynamic File Name attachment in Mail Adpater

    Hi All,
    We have Requirement where we need attach file with Dynamic Names in mail adapter PI7.0 .Right now we are using some of the modules to genarate file attachement with hard coded value for name of the file.
    Java beans we are using are
    localejbs/AF_Modules/StrictXml2PlainBean
    localejbs/AF_Modules/MessageTransformBean
    localejbs/AF_Modules/TextCodepageConversionBean
    sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
    Please let us know how we can acheive this.
    Thanks,
    Madhu

    Hi Madhusudhan,
    File attachment with the dynamic name is possible by using the Adapter module as well as without the Adpater module through coding.
    let me know which kind of attachment you want in mail and which is your sending system (like SAP R/3)?
    Thanks & Regards
    Jagesh

  • Send file as attachment via mail

    Dear All,
    I want to send a report (ALV) as attachment to some mail. I am using SO_NEW_DOCUMENT_SEND_API1. Can you please suggest how can I send mail as attachment. I am able to send ALV report as HTML format. I want to send it as attachment.
    Thanks and regards,
    Atanu

    Hi,
    plz check the below code.
    it sends Excel sheet attachment with the mail using FM 'SO_DOCUMENT_SEND_API1'
    code>>>>>>>>>>>>>>>>>>>>.
    form send_email_with_attachment .
    DATA: l_t_objbin LIKE solisti1 OCCURS 100 WITH HEADER LINE.
      DATA: i_body TYPE soli_tab WITH HEADER LINE.
      DATA: l_t_objtxt  LIKE solisti1   OCCURS 100 WITH HEADER LINE.
      DATA: l_t_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
      DATA: l_t_objhead LIKE solisti1   OCCURS 1 WITH HEADER LINE.
      DATA: l_t_reclist LIKE somlreci1  OCCURS 5 WITH HEADER LINE.
      DATA: w_tabln TYPE i .              "for number of table lines
      DATA: w_line        TYPE so_text255.       " Line of text
      DATA: l_doc_chng  LIKE sodocchgi1.
      DATA: l_tab_lines LIKE sy-tabix.
      DATA: l_att_lines TYPE i.
      DATA: lv_lines  TYPE i.
      DATA : BEGIN OF wa_mrpnm,
               werks TYPE ZCSVT024D-werks,
               dispo TYPE ZCSVT024D-dispo,
               name_first TYPE ZCSVT024D-name_first,
               name_last  TYPE ZCSVT024D-name_last,
             END OF wa_mrpnm,
             l_i_mrpnm LIKE STANDARD TABLE OF wa_mrpnm.
      DATA : l_name TYPE string.
    *Used for delimiting the columns in Excel Sheet.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      CONSTANTS:
      cr_mark(2) TYPE c VALUE cl_abap_char_utilities=>horizontal_tab.
      constants c_l_newline type ABAP_CHAR1 value %_NEWLINE. "#EC NOTEXT
      CLEAR : l_t_objpack,
      l_t_objhead,
      l_t_objbin,
      l_t_objtxt,
      l_t_reclist.
      REFRESH: l_t_objpack,
      l_t_objhead,
      l_t_objbin,
      l_t_objtxt,
      l_t_reclist.
    Creating the content of the e-mail message text
      IF sy-sysid(1) = 'P'.
        IF p_order = 'X'.
         l_doc_chng-obj_name   = 'Subcontracting Setup Report'(m02).
          CONCATENATE 'Details of Orders Extract'(028) 'for Plant'(029)
                       p_werks
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ELSE.
         l_doc_chng-obj_name   = 'TEST ONLY!! SC Setup Report'(m03).
          CONCATENATE 'Details of Forecast Extract'(030) 'for Plant'(029)
                       p_werks
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ENDIF.
      ELSE.
        IF p_order = 'X'.
         l_doc_chng-obj_name   = 'Subcontracting Setup Report'(m02).
          CONCATENATE 'Details of Orders Extract'(028) 'for Plant'(029)
                       p_werks 'TEST TEST TEST'
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ELSE.
         l_doc_chng-obj_name   = 'TEST ONLY!! SC Setup Report'(m03).
          CONCATENATE 'Details of Forecast Extract'(030) 'for Plant'(029)
                       p_werks 'TEST TEST TEST'
                       INTO l_doc_chng-obj_descr SEPARATED BY space.
          l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt ).
        ENDIF.
      ENDIF.
      l_t_objtxt = 'Hi,'(036).
      APPEND l_t_objtxt.
      CLEAR l_t_objtxt.
      APPEND l_t_objtxt.
      CONCATENATE 'Please open the attachment to review details of the Report'(031)
                  'for plant'(029) p_werks INTO l_t_objtxt
                   SEPARATED BY space.
      APPEND l_t_objtxt.
      CLEAR l_t_objtxt.
      APPEND l_t_objtxt.
      DESCRIBE TABLE t_ddow LINES sy-tfill .
      IF sy-tfill GT 0 .
        MOVE 'These Materials have been marked as DDOW materials.'(032)
                TO l_t_objtxt.
        APPEND l_t_objtxt.
        CLEAR l_t_objtxt.
        APPEND l_t_objtxt.
        APPEND l_t_objtxt.
        APPEND l_t_objtxt.
        CONCATENATE 'Note! - This is an automatically generated email by the'(034)
                         'SAP system. Pls do not reply to the sender.'(035)
                   INTO  l_t_objtxt
                   SEPARATED BY space.
        APPEND l_t_objtxt.
        DESCRIBE TABLE l_t_objtxt LINES l_tab_lines.
        READ TABLE l_t_objtxt INDEX l_tab_lines.
       l_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( l_t_objtxt )
      Creating the entry for the email text in the packing list
        CLEAR l_t_objpack-transf_bin.
        l_t_objpack-head_start = 1.
        l_t_objpack-head_num = 1.
        l_t_objpack-body_start = 1.
        l_t_objpack-body_num = l_tab_lines.
        l_t_objpack-doc_type = 'RAW'.
        lv_lines = l_tab_lines.
        APPEND l_t_objpack.
    Columns Heading for Excel Attachment.
        CONCATENATE  'MRP Controller'(044)
                     'MRP Name'(047)
                     'Material'(037)
                     'Plant'(026)
                     'PP Cal'(038)
                     'Ship Date'(009)
                     'PO Number'(014)
                     'PO Line'(033)
                     'PP Text'(041)
             INTO i_body
            SEPARATED BY cr_mark.
        concatenate ' ' i_body into i_body separated by c_l_newline.
        APPEND i_body TO l_t_objtxt.
        CLEAR i_body.
      Get MRP Names
        SELECT werks dispo name_first name_last
          FROM ZCSVT024D
          INTO TABLE l_i_mrpnm
          FOR ALL ENTRIES IN t_ddow
          WHERE werks = t_ddow-werks
            AND dispo = t_ddow-dispo.
        IF sy-subrc = 0.
          SORT l_i_mrpnm by werks dispo.
        ENDIF.
    Data to be shown in Excel Sheet.
        LOOP AT t_ddow INTO w_ddow.
          CLEAR : l_name.
          READ TABLE l_i_mrpnm INTO wa_mrpnm WITH KEY werks = w_ddow-werks
                                                      dispo = w_ddow-dispo
                                                      BINARY SEARCH.
          IF sy-subrc = 0.
            CONCATENATE wa_mrpnm-name_first wa_mrpnm-name_last
              INTO l_name SEPARATED BY space.
          ENDIF.
          CONCATENATE  w_ddow-dispo
                       l_name
                       w_ddow-matnr
                       w_ddow-werks
                       w_ddow-mrppp
                       w_ddow-datum
                       w_ddow-ebeln
                       w_ddow-ebelp
                       w_ddow-pptxt
                INTO i_body
            SEPARATED BY cr_mark.
          concatenate ' ' i_body into i_body separated by c_l_newline.
          APPEND i_body TO l_t_objtxt.
          CLEAR : w_ddow.
        ENDLOOP.
        DESCRIBE TABLE l_t_objtxt LINES l_tab_lines.
        DESCRIBE TABLE l_t_objtxt LINES l_att_lines.
        l_tab_lines = l_tab_lines - lv_lines.
      Creating the entry for attachment in the packing list
      objpack-transf_bin = 'X'.
        lv_lines = lv_lines + 1.
        l_t_objpack-head_start = 2.
        l_t_objpack-head_num = 1.
        l_t_objpack-body_start = lv_lines.
        l_t_objpack-body_num = l_tab_lines.
        l_t_objpack-doc_type = 'XLS'.
        l_t_objpack-obj_name = 'DDOW_Materials'(045).
        l_t_objpack-obj_descr = 'DDOW Marked Materials'(046).
        l_t_objpack-doc_size = l_tab_lines * 255.
        APPEND l_t_objpack.
        lv_lines = l_att_lines.
         **RECEIVERS...
        LOOP AT t_ddow INTO w_ddow.
          REFRESH l_t_reclist .
          CLEAR l_t_reclist.
    * get the MRP controller from table
          READ TABLE t_mrpc INTO w_mrpc WITH KEY werks = p_werks
                                                 dispo = w_ddow-dispo
                                                 BINARY SEARCH .
          IF sy-subrc EQ 0 .
            MOVE: 'X'               TO l_t_reclist-express   ,
                  'U'               TO l_t_reclist-rec_type  ,
                  w_mrpc-smtp_addr  TO l_t_reclist-receiver  .
                  APPEND l_t_reclist.
            EXIT.
          ENDIF.
        ENDLOOP.
      Sending the document
        IF NOT l_t_reclist[] IS INITIAL.
          CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
            EXPORTING
              document_data              = l_doc_chng
              commit_work                = 'X'
            TABLES
              packing_list               = l_t_objpack
              object_header              = l_t_objhead
              contents_bin               = l_t_objbin
              contents_txt               = l_t_objtxt
              receivers                  = l_t_reclist
            EXCEPTIONS
              too_many_receivers         = 1
              document_not_sent          = 2
              operation_no_authorization = 4
              OTHERS                     = 99.
        ENDIF.
        IF sy-subrc <> 0.
    * Do nothing
        ELSE.
          COMMIT WORK AND WAIT.
          MESSAGE s899(8a) WITH 'Email Message sent successfully'."#EC
        ENDIF.
      ENDIF.
    <<<<<<<<<<<<<<<<<<<<<<<
    regards,
    vikas.
    plz reward if helpful..

  • More than 255 characters required in excel send as attachment in mail.

    Hi Experts,
    I have a requirement to send displayed list in an ALV report as attachment in excel through mail. I have used FM SO_DOCUMENT_SEND_API1. Now the problem is my excel data in more than 255 characters in a line. It is about 400 characters.But it is taking upto 255 characters in the internal table which is passed to parameter contents_bin . This is because the internal table is of type SOLISTI1. But the excel should hold atleast 400 characters as per my requirement. How to overcome this issue ? Please suggest me...
    Regards,
    SURYA

    Say your records are exactly 400 length (I am saying 400 for sake of simplifying things, in reality record lengths can be variable and have to be calculated using STRLEN)
    You will cut the first record at 255 length and put it in first row. You will put next 145 characters in 2nd row, followed by newline characters (hex 0D and 0A) at positions 146 & 147 (which indicates end of record for excel, so that it puts next record in a new excel row).
    The second record will start from 148th character in second row till 255, that is 108 characters and will extend into 3rd row till 400 - 108 = 292th character followed by newline characters (hex 0D and 0A) at postions 293 & 294, followed by contents of 3rd record and so on and so forth.
    If you records are of variable length you can also think of always blank padding them to create a record of such a fixed length that always your records are lesser than that and fit into it. This will leave some blank spaces at the end of each record in excel, which may be fine.

  • File With Attachment to Mail with Attachment

    I'm developing above scenario. I want to retain the name of the attachment. Is it possible to do with UDF ?. Attachment is in csv format and Main file may be txt format.

    Use MessageTransformBean module in adapter configuration to achieve this.
    Enter "localejbs/AF_Modules/MessageTransformBean" as the module. Select the Type "Local Enterprise Bean" and select a value for Module Key. Use this module key to create the following three lines in Module Configuration:
    Transform.ContentDisposition attachment;filename="myfilename.csv"
    Transform.ContentDescription myfilename.csv
    Transform.ContentType application/xls;name="myfilename.csv"
    Regards,
    TK

Maybe you are looking for