Mail via SAP ABAP Coding.........
*******************Send mail in SAP ABAP**************************
* Data Declarations 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 LT_MAILRECIPIENTS-REC_TYPE = 'U'. LT_MAILRECIPIENTS-RECEIVER = 'sheetal@gmail.com'. APPEND LT_MAILRECIPIENTS . CLEAR LT_MAILRECIPIENTS . * Subject. LT_MAILSUBJECT-OBJ_NAME = 'TEST'. LT_MAILSUBJECT-OBJ_LANGU = SY-LANGU. LT_MAILSUBJECT-OBJ_DESCR = 'Mail Subject'. * Mail Contents LT_MAILTXT = 'This is a test mail'. APPEND LT_MAILTXT. CLEAR LT_MAILTXT. * Send Mail 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.
****************End ************************************************
Sheetal Gulati
sap.miniarora@gmail.com
7 Comments
Anonymous
Good and easy one...
Sheetal
Santosh kotagi
Thanks sheetal
Former Member
Hi Guys,
I am working on this mail object and return code of Fm 'SO_NEW_DOCUMENT_SEND_API1' is '0'. But mail shouldnt sent to receiver.
So i checked the SAPConnect (Tcode - SOST), my mail was in queue with status 'WAITING'. Lond Text of message is below -
Definition
A message was sent by the application. The status of the message is 'Waiting'.
Use
The message is in the queue. The SAPconnect send process will send the message during the next run.
My requirement is immediate mail sent. no need to wait for next run. What should i do in this case, either talk to IT dept or is their any ABAP solution. Plz Help and reply ASAP.
Thanks and Regard..
Pratyaksh Jeet
ABAP & BI Consultant
+91-9650963884
pratyakshjeet@3iconsulting.in
Former Member
Hi Pratyaksh,
I dont know if you solved your Problem - I think so - but I have had the same too.
The solution in my case was that automatical sending has been deactivated in the development system.
Manually sending via transaction SOST lead to sending of ALL documents in the queue ... now I know that.
Regards,
Stefanie
ram g
when i execute this code its not working ......(is it working sap to gmail)
Former Member
Good Day,
Just wanted to say thanks. This was very helpful for me with a requirement I have.
Vivin Gomez
What mode is 'INT'?
Does this send the mail immediately?