Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

                                                                 
Mail via SAP ABAP Coding.........                                                                     
                      *******************Send mail in SAP ABAP**************************

Error rendering macro 'code': Invalid value specified for parameter 'lang'
* 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 ************************************************
(thumbs up)  Sheetal Gulati

sap.miniarora@gmail.com

9 Comments

  1. Good and easy one...

    Sheetal

  2. 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

     

  3.  

    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

  4. when i execute this code  its not working ......(is it working sap to gmail)

  5. Good Day, 

    Just wanted to say thanks. This was very helpful for me with a requirement I have. 

  6. What mode is 'INT'?

    Does this send the mail immediately?

  7. Vivin 

    It is Interenet

  8. Hi Guys ,

    I have had the same problem as pratyaksh has ,

    I am working on this mail object and return code of Fm 'SO_NEW_DOCUMENT_SEND_API1' is '0'. But did not get any  to receiver.

    So i checked the SAPConnect (Tcode - SOST), my mail was in queue with status 'WAITING'. 

    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.