Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

My code to send email does not work...

Hello experts,

I am trying to send email to users after adding a new record. Now, it does not work properly. Below is the code I made. Please help me out on this guys. Again, thank you guys and have a nice day!

  • For API

DATA: maildata TYPE sodocchgi1.

DATA: mailtxt TYPE TABLE OF solisti1 WITH HEADER LINE.

DATA: mailrec TYPE TABLE OF somlrec90 WITH HEADER LINE.

CLEAR: maildata, mailtxt, mailrec.

REFRESH: mailtxt, mailrec.

maildata-obj_name = 'TEST'.

maildata-obj_descr = 'Test'.

maildata-obj_langu = sy-langu.

mailtxt-line = 'This is a test'.

APPEND mailtxt.

SELECT * FROM zshipto_email

INTO TABLE it_zshipto_email.

LOOP AT it_zshipto_email.

mailrec-receiver = it_zshipto_email-zemail.

mailrec-rec_type = 'U'.

APPEND mailrec.

ENDLOOP.

delete mailrec where receiver is initial.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

document_type = 'RAW'

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

commit work.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Message was edited by: viraylab

Tags:
replied

Hi again,

1. For this u will have to take help

of basis team,

for proper settings of SCOT.

2. If u can see your email message

in scot (waiting for send)

then your code is working fine.

3. Only scot settings( which are done by basis team)

will need to be done/corrected.

regards,

amit m.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question