Application Development 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: 

how to send body of email when using so_object_send

Former Member
0 Kudos

hi folks,

do you know how to send body of an email when email sending with FM SO_OBJECT_SEND.

i am using objcont parameter but the body is not coming.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi ,

You must populate the table parameter objcont for email body content. for more details please search in SCN.

I would suggest you to use the BCS classes because the fm you have mentioned will not support chinese,japanese etc characters in unicode environment.

Goto se38 and search f4 for BCSexample, you will get the examples for how to use BCS Classes for attachments,body content etc.

6 REPLIES 6

Former Member
0 Kudos

Hi Niraja,

Instead of the FM you can use the class cl_bcs to send the email. Below is the sample code

REPORT zemail_test.

DATA: lv_message TYPE bcsy_text,
      lv_send_result TYPE c,

lo_receiver TYPE REF TO if_recipient_bcs,

lo_email 	TYPE REF TO cl_bcs,
lo_email_body 	TYPE REF TO cl_document_bcs,

lx_exception TYPE REF TO cx_bcs.

APPEND '<font color="#0000FF">Hello World... This is a test email!</font>' TO lv_message.

TRY.

lo_email = cl_bcs=>create_persistent( ).
lo_email_body = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = lv_message
i_subject = 'Message from SAP BCS' ).

lo_email->set_document( lo_email_body ).

lo_receiver = cl_cam_address_bcs=>create_internet_address( 'someone @ somewhere.com' ).
lo_email->add_recipient( i_recipient = lo_receiver
i_express = 'X' ).

lo_email->set_send_immediately( 'X' ).

lo_email->send( EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = lv_send_result ).

WRITE: / 'Message sent successfully', lv_send_result.

COMMIT WORK.

CATCH cx_bcs INTO lx_exception.

WRITE:/ 'Message failed:', lx_exception->error_type.

ENDTRY.

Hope this helps you...

Thanks

Satya

0 Kudos

i need to even send attachments in the emails

and attachments are working fine with the so_object_send.

how to send attachmetns with the way u told

kesavadas_thekkillath
Active Contributor
0 Kudos

Hi ,

You must populate the table parameter objcont for email body content. for more details please search in SCN.

I would suggest you to use the BCS classes because the fm you have mentioned will not support chinese,japanese etc characters in unicode environment.

Goto se38 and search f4 for BCSexample, you will get the examples for how to use BCS Classes for attachments,body content etc.

0 Kudos

hi i have looked into BCS* programs and copied one of when i try to open the attachment in SOSt, it says file may be corrupted or wrongly decoded what is thi?

0 Kudos

is it a pdf ?

if so search in scn with the error meesage, this is discussed many times

Edited by: Keshav.T on Aug 25, 2010 4:22 AM

0 Kudos

what error message shall i search?

also there was anotehr program which was telling that it creates a document .. but when i see the attachment, it doesnt have any extension..

it just says in code as type = RAW.