Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using BCS classes to send emails with attachments

Former Member
0 Likes
1,831

Hi,

Basically, the code looks like:

  document = cl_document_bcs=>create_document(
                      i_type    = 'RAW'
                      i_text    = lt_text
                      i_subject = subject ).

* add sender
* add recipient

* read the documents I want to send

LOOP AT lt_list_files INTO ls_list_files.
	

             CALL METHOD document->add_attachment
                  EXPORTING
                    i_attachment_type     = 'DOC'
                    i_attachment_subject  = file_name
                    I_ATT_CONTENT_HEX     = lt_content_hex.

ENDLOOP.

* add our document (and its attachments) to send request.
      CALL METHOD send_request->set_document( document ).

* set send immediately flag
       send_request->set_send_immediately( 'X' ).

* Send document
       call method send_request->send( ).

    COMMIT WORK.

The problem is that if I send attachments lt_text becomes an attachment too (!?!) and I want it to be the E-Mail Body. Without attachments lt_text is sent as expected as an E-Mail Body.

Why’s that ?

Mihai

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
778

Hi Mihai,

Not sure if this is what you are looking for, but there seems to be a SAP Note 489848, which you might want to refer.

If you have not already done so, you can try experimenting with the methods CREATE_FROM_TEXT and ADD_DOCUMENT_AS_ATTACHMENT.

Regards,

Anand Mandalika.

3 REPLIES 3
Read only

Former Member
0 Likes
779

Hi Mihai,

Not sure if this is what you are looking for, but there seems to be a SAP Note 489848, which you might want to refer.

If you have not already done so, you can try experimenting with the methods CREATE_FROM_TEXT and ADD_DOCUMENT_AS_ATTACHMENT.

Regards,

Anand Mandalika.

Read only

Former Member
0 Likes
778

Thank you !

This is the solution (edited from 'This seems to be the answer'.)

I also discovered () the function SO_DOCUMENT_SEND_API1 that enables one to specify the sender as well. I knew only SO_NEW_DOCUMENT_ATT_SEND_API1 but the problem was that in the sent email ‘From’ shows the email of the user <[email protected]> who executed the program that called this function and I needed in ‘From’ to be a generic email address something like [email protected].

Because of that I tried to use BCS classes

Message was edited by: Mihai Olaru

Read only

Former Member
0 Likes
778

Hello,

I have s special question concerning the BCS class.

Is it possible to attach a SAP-Object ?

Example purchase order

obj bus2012

What method of cl_document_bcs can be used?

Do I have to create any kind of persistence before

calling a mehod?

Markus