Skip to Content
avatar image
Former Member

Mail excel sheet


I create an excel sheet using the following code:


CALL METHOD OF excel_app 'Workbooks' = excel_workbook NO FLUSH.

CALL METHOD OF excel_workbook 'Add' = excel_sheet NO FLUSH.

The parameters excel_app, excel_workbook and excel_sheet are OLE2_OBJECT objects.

Further more addtion calls to fill the sheet are done.

To display the sheet the following code:

SET PROPERTY OF excel_app 'Visible' = 1 no flush.

This is working and on the client the excel sheet is displayed.

The change I need to make is not to display the excel sheet but mail that sheet.

I have searched a lot here on sdn, google etc but found nothing how to do that.

One option would be to save the sheet on a file system and add that as attachment but in my opinion that's not the solution.

What would be an other option?


Patrick Willems

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    May 11, 2011 at 09:11 AM

    Please use the attachment concept, while sending email.

    You can achieve this through the class method.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Brad Bohn

      Hallo Brad,

      I tried to follow your advise, as I was using SO_NEW_DOCUMENT_ATT_SEND_API1 and it worked fine for me, but I wanted to use CL_BCS methods.

      My problem is that I need to attach an axcel file formatted with xml, but if I use the add_attachment method the result is an empty file, even if with the SO_NEW_DOCUMENT_ATT_SEND_API1 I was able to send the file.

      here is an extracr of the code I am using

      CALL METHOD w_document->add_attachment "w_document TYPE REF TO cl_document_bcs


      i_attachment_type = 'xls'

      i_attachment_size = w_size "DESCRIBE TABLE t_solix LINES w_size.

      i_attachment_subject = 'file.xls'

      i_att_content_hex = t_solix[]. "t_solix TYPE solix_tab.

      CALL METHOD w_send_req->set_document( w_document ). "w_send_req TYPE REF TO cl_bcs,

      Is there anything wrong?

      Thanks in advance for any help.

      Edited by: Moody973 on Jun 6, 2011 5:33 PM

  • avatar image
    Former Member
    Jun 06, 2011 at 08:17 PM

    Hi Patrick

    As you are using OLE objects for creating the excel file, you cannot mail the spreadsheet unless you download and upload again, and then use BCS class methods.

    Only option i can think of is is to use the statement


    from your workbook, this will open your outlook email and attach the file you have opened. But again there is lot of drawback with this approach, this will work only for MS Outlook, MS outlook should be installed on the client etc.

    Alternatively if your excel is simple one without much formatting and other functions/macros, i would suggest to create a csv file and mail it from the program.

    Note : Might be aware of the performance, when using the OLE objects.



    Add comment
    10|10000 characters needed characters exceeded

  • Jun 07, 2011 at 05:27 AM


    Check this out.

    Add comment
    10|10000 characters needed characters exceeded