10-12-2008 11:15 AM
Hi all,
could u pls answer my thread...
i want the class name for sending 2 mail attachment at a time.........
thanks®ards
rahul........
10-12-2008 11:31 AM
10-13-2008 7:58 AM
Hi Rahul,
As mentioned in the above thread, BCS Classes are
used for this purpose...
To achieve this, we have to create a document (instance of
cl_document_bcs) and link it to the mailer object (instance of
cl_bcs).
The class cl_document_bcs has a method add_attachment.
We can use this to add attachments (more than one).
Check the sample code below where I have attached a text file
twice.
Also there are many std demo programs starting with BCS_.
DATA: send_request TYPE REF TO cl_bcs,
lt_text TYPE bcsy_text, " Message body
lt_attach TYPE soli_tab, " Attachment content
document TYPE REF TO cl_document_bcs,
recipient TYPE REF TO cl_cam_address_bcs,
bcs_exception TYPE REF TO cx_bcs,
lv_error_txt TYPE string,
sent_to_all TYPE os_boolean.
PARAMETERS p_mailid TYPE adr6-smtp_addr.
TRY.
send_request = cl_bcs=>create_persistent( ).
APPEND 'Test message' TO lt_text.
document = cl_document_bcs=>create_document( i_type = 'RAW'
i_text = lt_text
i_subject = 'Check this' ).
APPEND 'Test Attachment' TO lt_attach.
document->add_attachment( EXPORTING i_attachment_type = 'RAW' " First Attachment
i_attachment_subject = 'attach1.txt'
i_att_content_text = lt_attach ).
document->add_attachment( EXPORTING i_attachment_type = 'RAW' " Second Attachment(same docu)
i_attachment_subject = 'attach2.txt'
i_att_content_text = lt_attach ).
send_request->set_document( document ).
recipient = cl_cam_address_bcs=>create_internet_address( p_mailid ).
send_request->add_recipient( EXPORTING i_recipient = recipient
i_express = 'X' ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
lv_error_txt = bcs_exception->get_text( ).
WRITE:`Error : ` , lv_error_txt.
EXIT.
ENDTRY.
.
Note: Issued mails can be checked in tcode SOST
Cheers,
Jose.