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: 

Need to send hr letter in mail body along with attachments

ravigrover
Participant
0 Kudos

Dear all

Need to send hr letter in mail body along with attachments.

We have requriement where we have to send formated letter in the email body along with the few attachment of different types like doc, xls and pdf.

we have 5 letters and their respected attachmetns depending upon condtitions.

Solution i have in my mind is to create letter in SO10 and call this in abap program using read_text fm and send to the receiver the text as well attachment data by SO_NEW_DOCUMENT_ATT_SEND_API1.

i have idea ( may be wrong), but dont know how to implement it.

Edited by: ravihsr on Mar 18, 2011 7:16 AM

1 ACCEPTED SOLUTION

rahul_mb
Active Participant
0 Kudos

Hi,

First read the letter content using READ_TEXT FM. Now declare an internal table of type SOLISTI1 and move the leter content to this internal table. Now call the SO_NEW_DOCUMENT_ATT_SEND_API1 FM and pass the internal table as the CONTENTS_TXT TABLE parameter of the FM.

Thanks and Regards,

Rahul Muraleedharan.

3 REPLIES 3

rahul_mb
Active Participant
0 Kudos

Hi,

First read the letter content using READ_TEXT FM. Now declare an internal table of type SOLISTI1 and move the leter content to this internal table. Now call the SO_NEW_DOCUMENT_ATT_SEND_API1 FM and pass the internal table as the CONTENTS_TXT TABLE parameter of the FM.

Thanks and Regards,

Rahul Muraleedharan.

0 Kudos

Thanks Rahul for your instant reply.

See the body content is differrent and files to be attached are different.

Ravi

Former Member
0 Kudos

Hi Ravihsr,

REPORT Z02_TEST_EMAIL.

  • Mail related

DATA: i_content TYPE soli_tab, " Mail content

i_attach TYPE soli_tab. " Attachment

DATA: l_text TYPE char255. " Text

DATA: l_send_request TYPE REF TO cl_bcs,

" E-Mail Send Request

l_document TYPE REF TO cl_document_bcs,

" E-Mail Attachment

l_recipient TYPE REF TO if_recipient_bcs ,

" Distribution List

l_sender TYPE REF TO if_sender_bcs,

" Address of Sender

l_uname TYPE salrtdrcpt,

" Sender Name(SY-UNAME)

l_bcs_exception TYPE REF TO cx_document_bcs,

" BCS Exception

l_addr_exception TYPE REF TO cx_address_bcs,

" Address Exception

l_result TYPE sy-binpt,

l_send_exception TYPE REF TO cx_send_req_bcs.

" E-Mail sending Exception

MOVE 'Mail Body' TO l_text.

APPEND l_text TO i_content.

move '123' to l_text.

APPEND l_text TO i_content.

  • Creates persistent send request

TRY.

l_send_request = cl_bcs=>create_persistent( ).

  • Creating Document

l_document = cl_document_bcs=>create_document(

i_type = 'RAW'

i_text = i_content[]

i_subject = 'test mail' ).

CALL METHOD v_document->add_attachment

EXPORTING

i_attachment_type = 'XLS' "FOR xls FILE,

i_attachment_size = lv_size " THIS IS THE SIZE OF THE ATTACHEMENT

i_attachment_subject = lv_sub "THIS THE NAME OF THE ATTACHEMNT

i_att_content_text = t_html2[]. "THIS THE ATTACHMENT IE THE FILE

*l_o_sender = cl_cam_address_bcs=>create_internet_address( v_address ).

  • Add document to send request

CALL METHOD l_send_request->set_document( l_document ).

  • Get Sender Object

l_uname = sy-uname.

l_sender = cl_sapuser_bcs=>create( l_uname ).

CALL METHOD l_send_request->set_sender

EXPORTING

i_sender = l_sender.

l_recipient = cl_cam_address_bcs=>create_internet_address( rec ) "mail id where the mail is to be send

.

CALL METHOD l_send_request->add_recipient

EXPORTING

i_recipient = l_recipient

i_express = 'U'

i_copy = ' '

i_blind_copy = ' '

i_no_forward = ' '.

*Trigger E-Mail immediately

l_send_request->set_send_immediately( 'X' ).

CALL METHOD l_send_request->send(

EXPORTING

i_with_error_screen = 'X'

RECEIVING

result = l_result ).

.

COMMIT WORK.

CATCH cx_document_bcs INTO l_bcs_exception.

CATCH cx_send_req_bcs INTO l_send_exception.

CATCH cx_address_bcs INTO l_addr_exception.

ENDTRY.

Try this one

Thanks and regards,

Sri Hari Anand Kumar