Skip to Content

Download mail attachments in a zip file

My task is to create a button for the e-mail attachments view in the CRM WebUI and as soon as user click on that button all the attachments should be downloaded in zip format.

I am new in this area and it is really complicated for me to figure out how to do this.
I am finding some variants to do that, but for them, first of all I have to get the GUID, object type, or at least the id.

How can I do that?
I've created an enhancement for CRMCMP_CCS_EML component and after that an event handler for a button within the MailAttachments view.
In that event handler I am trying to get the GUID using this code:

INCLUDE crm_object_names_con.DATA : lr_entity TYPE REF TO cl_crm_bol_entity,

lv_collection TYPE REF TO if_bol_bo_col,
lv_guid TYPE crmt_object_guid,
lr_comp TYPE REF TO zl_crmcmp_c_bspwdcompone1_impl,
lt_request_objs TYPE crmt_object_name_tab,
lt_header_guids TYPE crmt_object_guid_tab,
lt_orderadm_h TYPE crmt_orderadm_h_wrkt,
ls_orderadm_h LIKE LINE OF lt_orderadm_h,
lv_obj_type TYPE crmt_swo_objtyp_process_itm_db.

lr_comp ?= me->comp_controller.CHECK lr_comp IS BOUND.

*obtaining email guid
lr_entity ?= lr_comp->typed_context->btadminh->collection_wrapper->get_current( ).
lr_entity->get_property_as_value( EXPORTING iv_attr_name = 'GUID'IMPORTING ev_result = lv_guid ).
INSERT gc_object_name-orderadm_h INTO TABLE lt_request_objs.APPEND lv_guid TO lt_header_guids.
*obtaining object typeCALL FUNCTION 'CRM_ORDER_READ'EXPORTING
it_header_guid = lt_header_guids
it_requested_objects = lt_request_objs
iv_no_auth_check = 'X'IMPORTING
et_orderadm_i = lt_orderadm_hEXCEPTIONS
document_not_found = 1
error_occurred = 2
document_locked = 3
no_change_authority = 4
no_display_authority = 5
no_change_allowed = 6.
READ TABLE lt_orderadm_h INTO ls_orderadm_h INDEX 1 TRANSPORTING object_type.
lv_obj_type = ls_orderadm_h-object_type.


But without any success. If e-mail is an workitem and it doesn't have GUID, I am trying to obtain at least it's id using:

DATA tmp_object TYPE swotobjid.
CALL METHOD cl_swf_evt_requester=>get_workitem
IMPORTING
ex_workitem = tmp_object.

or

DATA: ld_requester_workitem TYPE swotobjid,
ld_requester_workitemid TYPE swotobjid-objkey.
CALL FUNCTION 'SWE_WI_GET_FROM_REQUESTER'
IMPORTING
requester_workitem = ld_requester_workitem
requester_workitemid = ld_requester_workitemid.

But it's also not working. Any suggestion?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Jan 21 at 10:20 PM

    Hi,

    attachments on this view should be generally accessible at typed context by this code snippet:

    DATA(lt_attachments) = me->typed_context->mail->currentattachments.
    Add comment
    10|10000 characters needed characters exceeded