Send mail using sap abap (OO)

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.