Welcome to SAP ABAP Interview Questions. How to Send Mail Using SAP ABAP Code Tutorial.
Dear ABAP programmers here in this post we are going to explain how to send email from SAP Screen to receiver mail address. Go to transaction code SE38 to write coding for mail sending from SAP ABAP Programming. Read this complete post to know more about SAP ABAP Mail Sending code.How to Send Mail Using SAP ABAP Source Code
First copy below code to your editor and change the receiver email to existing email address and execute to see the results.
Source Code for SAP ABAP Mail Sending
* Data Declarations for mail sending in SAP ABAP
DATA: lt_mailsubject TYPE sodocchgi1.
DATA: lt_mailrecipients TYPE STANDARD TABLE OF somlrec90 WITH HEADER LINE.
DATA: lt_mailtxt TYPE STANDARD TABLE OF soli WITH HEADER LINE.
* Recipients of mail
lt_mailrecipients-rec_type = 'U'.
lt_mailrecipients-receiver = 'receiver@gmail.com'.
APPEND lt_mailrecipients .
CLEAR lt_mailrecipients .
* Subject to send mail
lt_mailsubject-obj_name = 'TEST Mail'.
lt_mailsubject-obj_langu = sy-langu.
lt_mailsubject-obj_descr = 'Mail Subject Here'.
* Mail Contents to send
lt_mailtxt = 'This is a test mail using SAP ABAP'.
APPEND lt_mailtxt. CLEAR lt_mailtxt.
* Send Mail functionality in SAP ABAP
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = lt_mailsubject
TABLES
object_content = lt_mailtxt
receivers = lt_mailrecipients
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc EQ 0.
COMMIT WORK.
* Push mail out from SAP outbox
SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
ENDIF.
Find More : SAP ABAP Interview Questions for freshers and experienced
Find More Realtime SAP ABAP Webdynpro Interview Questions and Answers
Thanks for your reading this post on how to send mail using SAP ABAP Code.
"You found the information helpful and want to say thanks? Your donation is enough to inspire us to do more. Thanks a bunch!"
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.