云服务器价格_云数据库_云主机【优惠】最新活动-搜集站云资讯

金山云_网易企业邮箱手机版_排行榜

小七 141 0

Problem Description:

In CRM Pictures or Tables can be embedded in E-mails. When move these Emails to C4C, Emails transferred as a plain text and embedded objects like Pictures/Tables get lost. SAP transfer Emails as plain text instead of HTML text.

Sample Mail in CRM:

In this Email, 2 images and one table embedded

Mail transferred to C4C:

As you can see Email body transferred as only plain text, Images and table formatting lost from Email Body.

Solution:

As a solution I have converted Email Body in HTML format and Attach HTML file as an attachment to that Email. Now when we look in C4C there will be an HTML file (Name as "Original Email.html") attached to email and so users can view actual email as an attachment.

Here is the steps and code:

First understands how attachments files get transferred to C4C.

Function module "CRMPCD_ATTACHMENTS_TO_SOD" is used to transfer the attachment from CRM to C4C. In this function module, marked class and method is used to send attachments to C4C.

Inside this method, below marked class/method is called to execute Web Service "CO_CRMPCD_ATTACHMENT_FOLDER_RE" which actually transfer the attachments.

Double click on it above execute method, here you can see DO_EXECUTE method, Double click on it.

Here after method "export_convesion" I called a custom function module as below:

CALL FUNCTION ‘XXXXXXXXX’ TABLES tt_email_bo                = it_email_bo changing cs_attachment_folder       = ls_output1.

Now here is the code written in above custom function module which will convert Email body into HTML page and attach it to email.

DATA: lt_crmpcd1          TYPE crmpcd_attachment_folder_r_tab, ls_crmpcd1          TYPE crmpcd_attachment_folder_repli, lt_document         TYPE crmpcd_document_tab, ls_document         TYPE crmpcd_document,

ls_bo               TYPE sibflporb, lt_send_request     TYPE bcsy_guid, lo_appl_email_data  TYPE REF TO cl_crm_email_data, ls_body             TYPE crms_email_mime_struc, lv_send_request     TYPE os_guid,

lv_str              TYPE string, ls_attach           TYPE crms_email_mime_struc, lv_bd64_string      TYPE string, lv_pathname         TYPE string VALUE ‘/usr/sap/…./Original_Mail.html’,"Application server path from your system lv_data             TYPE xstring,

lt_header_guid      TYPE crmt_object_guid_tab, lv_header_guid      TYPE crmt_object_guid, lt_orderadm_h       TYPE crmt_orderadm_h_wrkt, ls_orderadm_h       TYPE crmt_orderadm_h_wrk, lv_activity_class   TYPE crmt_activity_class.

***Loop on all email objects LOOP AT tt_email_bo ASSIGNING FIELD-SYMBOL().

CLEAR: ls_bo, lt_send_request, lv_send_request, lo_appl_email_data, ls_body. ls_bo-instid    = -instid. ls_bo-typeid    = -typeid. ls_bo-catid     = -catid.

***This code is only for Email business activity BUS2000126 ***Also Try to check for Email IF -typeid NE ‘BUS2000126’. CONTINUE. ELSE. " Check if the current business activity is from the type email CLEAR: lt_header_guid. lv_header_guid  = ls_bo-instid. INSERT lv_header_guid INTO TABLE lt_header_guid.

" – Determine the process type CALL FUNCTION ‘CRM_ORDER_READ’ EXPORTING it_header_guid       = lt_header_guid IMPORTING et_orderadm_h        = lt_orderadm_h EXCEPTIONS document_not_found   = 1 error_occurred       = 2 document_locked      = 3 no_change_authority  = 4 no_display_authority = 5 no_change_allowed    = 6 OTHERS               = 7. IF SY-SUBRC NE 0. CONTINUE. ENDIF. CLEAR: lt_header_guid, ls_orderadm_h. READ TABLE lt_orderadm_h INTO ls_orderadm_h INDEX 1."#EC CI_SUBRC

" – Determine the activity Class. ‘G’: EMail, ‘F’: Appointment, … CALL FUNCTION ‘CRM_ORDER_ACTIVITY_H_SELECT’ EXPORTING iv_process_type   = ls_orderadm_h-process_type IMPORTING es_activity_class = lv_activity_class. *        EXCEPTIONS *          entry_not_found   = 1 *          OTHERS            = 2. IF lv_activity_class NE ‘G’. CONTINUE. ENDIF.

ENDIF.

***Get GUID of the email lt_send_request = cl_crm_email_utility=>get_mails_of_business_object( ls_bo ).

READ TABLE lt_send_request INTO lv_send_request INDEX 1. IF sy-subrc EQ 0.

***Get Email Data CALL METHOD cl_crm_email_utility=>get_mail_data_from_so EXPORTING iv_send_request_id = lv_send_request RECEIVING er_mail_data       = lo_appl_email_data EXCEPTIONS not_found          = 1.

***Read Email Body READ TABLE lo_appl_email_data->body INTO ls_body WITH KEY is_attachment = ‘ ‘ mime_type   = ‘text/html’. IF sy-subrc EQ 0.