2011 Oct 10 8:39 AM
In my requirement, I have to send an appointment with image as attachment, embedded (in display mode).
for creating document, I am using CL_DOCUMENT_BCS class, inside that class i am using
CREATE_FROM_MULTIRELATED method for creating the document. In this method we have to pass below object lo_mime_helper. Before passing it, I am filling it with image and appointment.
For image:
CALL METHOD lo_mime_helper->add_binary_part
EXPORTING
content = i_graphic_table
filename = 'WIPRO.BMP'
extension = 'BMP'
description = 'descriptiongif'
content_type = 'image/bmp'
length = l_len
content_id = 'content_id_1'.
For appointment
lv_sr_title = 'Invitaion for the Meeting'.
clear lt_text.
create document as an ica l object
lt_text = lo_appointment->as_ical_object( ).
*
*
CALL FUNCTION 'SO_RAW_INT_TO_RTF'
TABLES
objcont_old = lt_text
objcont_new = lt_text.
data wa_text like line of lt_text.
data text_length type i.
data full_length type i.
loop at lt_text INTO wa_text.
text_length = strlen( wa_text ).
full_length = full_length + text_length.
clear text_length.
CLEAR wa_text.
endloop.
clear l_len.
l_len = full_length.
CALL METHOD lo_mime_helper->add_textual_part
EXPORTING
content = lt_text
filename = 'Appointment Meeting'
extension = 'ICS'
description =
content_type = 'application/rtf'
LENGTH = l_len
content_id = 'content_id_2'
.
Now I am passing lo_mime_helper to methofd for creating document
TRY.
CALL METHOD cl_document_bcs=>create_from_multirelated
EXPORTING
i_subject = 'my subject'
i_multirel_service = lo_mime_helper
RECEIVING
result = document.
CATCH cx_document_bcs .
MESSAGE e672(so) WITH 'bcs error while creating bcs_doc'.
EXIT.
CATCH cx_bcom_mime .
MESSAGE e672(so) WITH 'mime error while creating bcs_doc'.
EXIT.
ENDTRY.
THis is sending a mail, but both image and appointment are going as attachment, even when I am setting Disposition type as I(Inline) in debugger. I want it to go as appointment with image embedded in body part.
When I am using CL_APPOINTMENT class, its going as appointment perfectly, but how to embedd a image in body part then.
In my requirement, I have to send an appointment with image as attachment, embedded (in display mode).
for creating document, I am using CL_DOCUMENT_BCS class, inside that class i am using
CREATE_FROM_MULTIRELATED method for creating the document. In this method we have to pass below object lo_mime_helper. Before passing it, I am filling it with image and appointment.
For image:
CALL METHOD lo_mime_helper->add_binary_part
EXPORTING
content = i_graphic_table
filename = 'WIPRO.BMP'
extension = 'BMP'
description = 'descriptiongif'
content_type = 'image/bmp'
length = l_len
content_id = 'content_id_1'.
For appointment
lv_sr_title = 'Invitaion for the Meeting'.
clear lt_text.
create document as an ica l object
lt_text = lo_appointment->as_ical_object( ).
*
*
CALL FUNCTION 'SO_RAW_INT_TO_RTF'
TABLES
objcont_old = lt_text
objcont_new = lt_text.
data wa_text like line of lt_text.
data text_length type i.
data full_length type i.
loop at lt_text INTO wa_text.
text_length = strlen( wa_text ).
full_length = full_length + text_length.
clear text_length.
CLEAR wa_text.
endloop.
clear l_len.
l_len = full_length.
CALL METHOD lo_mime_helper->add_textual_part
EXPORTING
content = lt_text
filename = 'Appointment Meeting'
extension = 'ICS'
description =
content_type = 'application/rtf'
LENGTH = l_len
content_id = 'content_id_2'
.
Now I am passing lo_mime_helper to methofd for creating document
TRY.
CALL METHOD cl_document_bcs=>create_from_multirelated
EXPORTING
i_subject = 'my subject'
i_multirel_service = lo_mime_helper
RECEIVING
result = document.
CATCH cx_document_bcs .
MESSAGE e672(so) WITH 'bcs error while creating bcs_doc'.
EXIT.
CATCH cx_bcom_mime .
MESSAGE e672(so) WITH 'mime error while creating bcs_doc'.
EXIT.
ENDTRY.
THis is sending a mail, but both image and appointment are going as attachment, even when I am setting Disposition type as I(Inline) in debugger. I want it to go as appointment with image embedded in body part.
When I am using CL_APPOINTMENT class, its going as appointment perfectly, but how to embedd a image in body part then.
2011 Nov 15 9:03 AM
Hi try with this code.
Document = cl_document_bcs=>create_document( i_type = u2018RAWu2019 i_text =
text i_length = u201912u2032 i_subject = u2018test created u2018 ).
add attachment to Document
BCS expects Document content here e.g. from Document upload
binary_content = u2026
CALL METHOD Document->add_attachment EXPORTING i_attachment_type = u2018GIFu2019
i_attachment_subject = u2018My attachmentu2019 i_att_content_hex =
binary_content.
add Document to send request
CALL METHOD send_request->set_document( Document ).
DATA: send_request TYPE REF TO cl_bcs.
DATA: text TYPE bcsy_text.
data: binary_content1 type STANDARD table OF TBL1024 WITH HEADER LINE.
data: binary_content type solix_tab.
DATA: Document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: bcs_exception type ref to cx_bcs.
data: sent_to_all type os_boolean.
send_request = cl_bcs=>create_persistent( ).
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender EXPORTING i_sender = sender.
recipient =
cl_cam_address_bcs=>create_internet_address( u2018 u2018 )
CALL METHOD send_request->add_recipient
EXPORTING i_recipient = recipient
i_express = u2018Xu2019.
CALL METHOD send_request->set_send_immediately( u2018Xu2019 ).
CALL METHOD send_request->send( exporting i_with_error_screen = u2018Xu2019
receiving result = sent_to_all ).
COMMIT WORK.endform.
<begging removed by moderator>
Regards
chitra
Edited by: Thomas Zloch on Nov 15, 2011 1:02 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |