SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Sending Mail from SAP

Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Mail
View previous topic :: View next topic  
Author Message

Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Sep 08, 2007 7:23 am    Post subject: Sending Mail from SAP Reply with quote

Description: In the Business Process Modeling Group I have seen alot of request regarding how to send mail notifications by using ABAP Code.
I have used the below mentioned code in several cases like
Info Letter to all Vendors, Sending PO Via Email, Reminder mails to the Agents in Workflow and also escalation mails to Process Owners when the task is not performed by the agents in the given time.

Prerequisite : SAP Enterprise Edition and above
SAP Connect needs to be configured
Mail Rely should be available

data reciever type table of ADR6-SMTP_ADDR.
data subject type SO_OBJ_DES.
data text type bcsy_text.
data line type soli-line.
data send_request type ref to cl_bcs.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs.
data sent_to_all type os_boolean.
data adresse type ADR6-SMTP_ADDR.
data mailflag(1) value space.

data dat(10).
data time(10).
data tfree(12).

write sy-datum to dat.
write sy-uzeit to time.

subject = 'This is my Subject '.
line = ' I am the body of the message '.

append line to text.

Mail Send Mail out to external Mail Server .

create the send request
send_request = cl_bcs=>create_persistent( ).
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_subject = betreff ).

add document to send request
send_request->set_document( document ).
create recipient and add to send request
adresse = ''.

recipient = cl_cam_address_bcs=>create_internet_address(
adresse ).
send_request->add_recipient( i_recipient = recipient ).

send mail now
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
if sent_to_all = 'X'.
message s022(so).

catch cx_bcs into bcs_exception.
message e865(so) with bcs_exception->error_type.

*Close Transaction.
commit work.

End of the Code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Mail All times are GMT + 4 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.