*&---------------------------------------------------------------------*
*& Report ZREP_CLS_029_SEND_EMAIL
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZREP_CLS_029_SEND_EMAIL.
*data declaration related to sap link creation fro trip.
********************************************************
data: wda_naame type string,
in_protocol type string,
out_host type string,
out_port type string,
out_protocol type string,
val type string,
g_url type string.
*data declaration related to mail
*********************************************************
data: send_request type ref to cl_bcs,
document type ref to cl_document_bcs,
send type ref to if_sender_bcs,
i_text type soli_tab,
wa_text type soli,
receiver type ref to if_recipient_bcs,
sent_to_all type os_boolean,
sender type adr6-smtp_addr,
recipient type adr6-smtp_addr,
subject type so_obj_des.
data:temp_addr type adr6-smtp_addr.
***************************************************************
* -generaating url for sap trasaction (sap gui for html)
***************************************************************
call method cl_http_server=>if_http_server~get_location
exporting
protocol = in_protocol
server = cl_wdr_task=>server
importing
host = out_host
port = out_port
out_protocol = out_protocol.
val = sy-mandt.
concatenate out_protocol '://' out_host ':' out_port '/sap/bc/gui/sap/its/ztrip' into g_url.
"/sap/bc/gui/sap/its/ patch for its service
"ztrip service name for tcode - trip,created thru sicf
call method cl_http_server=>append_field_url
exporting
name = 'sap-client'
value = val
changing
url = g_url.
*****************************************************
*sending mail to outlook with sap link
*****************************************************
send_request = cl_bcs=>create_persistent( ).
concatenate 'Dear SDN,' '' into wa_text-line.
append wa_text-line to i_text.
concatenate 'Please find below link for Travel Request (TRIP ),' '' into wa_text-line.
append wa_text-line to i_text.
concatenate '<a href="' g_url '" > Link to Travel Request </a>' ' ' into wa_text-line.
append wa_text-line to i_text.
subject = 'SDN: Mail to Outlook with Saplink'.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = i_text
i_length = '18'
i_subject = subject ).
*add document to send request
call method send_request->set_document( document ).
*create internet address for the sender
send = cl_cam_address_bcs=>create_internet_address(
i_address_string = 'SDN@SAP.COM'
i_address_name = 'SAP SDN').
*set the sender to send request instaance
call method send_request->set_sender
exporting
i_sender = send.
temp_addr = 'wangxi@163.com'. "Receiving address
receiver = cl_cam_address_bcs=>create_internet_address( temp_addr ). "adding receipts
call method send_request->add_recipient
exporting
i_recipient = receiver
i_express = 'X'.
send_request->set_send_immediately( 'X' ).
*sending the mail
call method send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
if sent_to_all = 'X'.
write :/ 'Mail has sent successfully'.
endif.
abap 发送邮件
最新推荐文章于 2024-08-26 10:06:52 发布