Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to send mail from ABAP code?

Former Member
0 Likes
660

Hi,

I need to send e-mail from ABAP Code .

e.g: If sy-subrc ne 0.

( send e-mail to "[email protected]" )

endif.

Please provide me any Function module for this or any code.

Correct answear will be rewarded my maximum points.

Thanks & Regards,

Gaurav.

Hi,

I need to send e-mail from ABAP Code .

e.g: If sy-subrc ne 0.

( send e-mail to "[email protected]" )

endif.

Please provide me any Function module for this or any code.

Correct answear will be rewarded my maximum points.

Thanks & Regards,

Gaurav.

3 REPLIES 3
Read only

Former Member
0 Likes
642

Try the Function Module

SO_NEW_DOCUMENT_ATT_SEND_API1

REgards.

Read only

Former Member
0 Likes
642
Read only

Former Member
0 Likes
642

Check this code sample

* Send mail
  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.
 
  loop at htmllines.
    mailtxt = htmllines.
    append mailtxt.
  endloop.
 
  mailrec-receiver = '[email protected]'.
  mailrec-rec_type  = 'U'.
  append mailrec.
 
  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       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  0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

Regards.