Post transferred from
Http://blog.csdn.net/lyb_yt/article/details/9495207
Try.
* Create a send request
Rochelle send_request = cl_bcs => create_persistent (
).
* Set the sent content
Rochelle document = cl_document_bcs => create_document (
I _type = 'Raw'
I _text
= I _content []
I _importance
= '1'
I _subject
= L_subject ).
* Add the content to send the request
Call method l_send_request-> set_document (
Rochelle document ).
* Get the sender (obtain the sender, provided that the email address can be sent without a password)
Rochelle uname = sy-uname.
Rochelle sender = cl_sapuser_bcs => Create (
Rochelle uname ).
Call method l_send_request-> set_sender
Exporting
I _sender = l_sender.
* Set recipients
Loop at it_mailaccept.
Concatenate it_mailaccept-name
'@ XXXXX. com'
Into I _email.
Translate I _email
Lower case.
Rochelle recipient = cl_cam_address_bcs => create_internet_address (
I _email ).
Call method l_send_request-> add_recipient
Exporting
I _recipient = l_recipient
I _express = 'X'
I _copy =''
I _blind_copy =''
I _no_forward = ''.
Endloop.
* Set CC recipients
Loop at it_mailaccept_copy.
Concatenate it_mailaccept_copy-name
'@ XXXXX
I _email.
Translate I _email
Lower case.
Rochelle recipient = cl_cam_address_bcs => create_internet_address (
I _email ).
Call method l_send_request-> add_recipient
Exporting
I _recipient = l_recipient
I _express = 'X'
I _copy = 'X'
I _blind_copy =''
I _no_forward = ''.
Endloop.
* & Send now
Rochelle send_request-> set_send_immediately (
'X ').
* & Send
Call method l_send_request-> send (
).
Commit work.
Catch cx_document_bcs
L_bcs_exception.
Catch cx_send_req_bcs
Rochelle send_exception.
Catch cx_address_bcs
Rochelle addr_exception.
Endtry.