*----------------------------------------------------------------------* * DECLARATIONS * *----------------------------------------------------------------------* DATA: gv_smtp_addr TYPE AD_SMTPADR, gs_aedi_def TYPE ZFAE_AEDI_DEF. DATA: gt_body TYPE BCSY_TEXT, gt_dat TYPE BCSY_TEXT, gt_txt TYPE BCSY_TEXT, gt_zip TYPE SOLIX_TAB, gs_body TYPE SOLI, gs_dat TYPE SOLI, gs_txt TYPE SOLI. *---------------------------------------------------------------------* * FORM BUILD_ZIP * *---------------------------------------------------------------------* FORM build_zip. DATA: lo_zipper TYPE REF TO CL_ABAP_ZIP, lv_xstring TYPE XSTRING, lv_filename TYPE STRING. CREATE OBJECT lo_zipper. IF gt_dat[] IS NOT INITIAL. CONCATENATE [...] INTO lv_filename. TRY. lv_xstring = cl_bcs_convert=>raw_to_xstring( it_soli = gt_dat iv_codepage = '4110' iv_add_bom = 'X' ). CATCH cx_bcs. MESSAGE E445(SO). ENDTRY. lo_zipper->add( name = lv_filename content = lv_xstring ). ENDIF. IF gt_txt[] IS NOT INITIAL. CONCATENATE [...] INTO lv_filename. TRY. lv_xstring = cl_bcs_convert=>raw_to_xstring( it_soli = gt_txt iv_codepage = '4110' iv_add_bom = 'X' ). CATCH cx_bcs. MESSAGE E445(SO). ENDTRY. lo_zipper->add( name = lv_filename content = lv_xstring ). ENDIF. lv_xstring = lo_zipper->save( ). TRY. gt_zip = cl_bcs_convert=>xstring_to_solix( lv_xstring ). CATCH cx_bcs. MESSAGE E445(SO). ENDTRY. ENDFORM. "build_zip *---------------------------------------------------------------------* * FORM SEND_AS_ATTACHMENT * *---------------------------------------------------------------------* FORM send_as_attachment. DATA: lo_mail TYPE REF TO CL_BCS, lo_document TYPE REF TO CL_DOCUMENT_BCS, lo_recipient TYPE REF TO IF_RECIPIENT_BCS, lo_exception TYPE REF TO CX_BCS, lv_sent_to_all TYPE OS_BOOLEAN, lv_filename TYPE SO_OBJ_DES. TRY. * mail lo_mail = cl_bcs=>create_persistent( ). * corpo della mail lo_document = cl_document_bcs=>create_document( i_type = 'RAW' i_text = gt_body i_subject = gs_aedi_def-obj_descr ). * allegati IF gt_dat[] IS NOT INITIAL. CONCATENATE [...] INTO lv_filename. lo_document->add_attachment( i_attachment_type = 'RAW' i_attachment_subject = lv_filename i_att_content_text = gt_dat ). ENDIF. IF gt_txt[] IS NOT INITIAL. CONCATENATE [...] INTO lv_filename. lo_document->add_attachment( i_attachment_type = 'RAW' i_attachment_subject = lv_filename i_att_content_text = gt_txt ). ENDIF. IF gt_zip[] IS NOT INITIAL. CONCATENATE [...] INTO lv_filename. lo_document->add_attachment( i_attachment_type = 'BIN' i_attachment_subject = lv_filename i_att_content_hex = gt_zip ). ENDIF. lo_mail->set_document( lo_document ). * destinatari lo_recipient = cl_cam_address_bcs=>create_internet_address( gv_smtp_addr ). lo_mail->add_recipient( lo_recipient ). * notifiche lo_mail->set_status_attributes( 'E' ). * invio lv_sent_to_all = lo_mail->send( i_with_error_screen = 'X' ). COMMIT WORK. IF lv_sent_to_all IS INITIAL. MESSAGE I500(SBCOMS) WITH gv_smtp_addr. ELSE. MESSAGE S022(SO). ENDIF. CATCH cx_bcs INTO lo_exception. MESSAGE I865(SO) WITH lo_exception->error_type. ENDTRY. ENDFORM. "send_as_attachment
martedì 10 novembre 2015
Inviare una mail con allegato zippato
Iscriviti a:
Commenti sul post (Atom)
Nessun commento:
Posta un commento