Application Development 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: 

Send Mail In SAP

Former Member
0 Kudos

I am trying to send mail from SAP R3 to an email address. I am using the function module SO_NEW_DOCUMENT_SEND_API1 to send the mail. The function Module is giving a return code 0 which means the mail has been sent.. but the users are not getting the mail.

I am attachin the piece of code for your info

Pls help.

s_doc_chng-obj_descr = text-020.

s_doc_chng-sensitivty = 'F'.

s_doc_chng-obj_langu = sy-langu.

s_doc_chng-no_change = 'X' .

s_doc_chng-expiry_dat = sy-datum + 30.

LOOP AT it_supervisor1 INTO s_supervisor1.

Population Of Email Ids Of The Receivers in the internal table

Population Of Employees Email Id.

s_reclist = s_supervisor1-userid_long.

s_reclist-rec_type = 'U'.

APPEND s_reclist TO it_reclist.

CLEAR s_reclist.

Population Of Supervisors Email Id

s_reclist = s_supervisor1-suserid_long.

s_reclist-rec_type = 'U'.

APPEND s_reclist TO it_reclist.

CLEAR s_reclist.

Population Of Personal Specialist Email Id

s_reclist = s_supervisor1-psuserid_long.

s_reclist-rec_type = 'U'.

APPEND s_reclist TO it_reclist.

CLEAR s_reclist.

Population Of The Email Text

CONCATENATE text-004 s_supervisor1-ename

text-005 INTO lv_mail SEPARATED BY space.

s_objbin-line = lv_mail.

APPEND s_objbin TO it_objbin.

CLEAR: s_objbin, lv_mail.

CONCATENATE text-006 s_supervisor1-fwocd INTO lv_mail

SEPARATED BY space.

s_objbin-line = lv_mail.

APPEND s_objbin TO it_objbin.

lv_dat1 = s_supervisor1-expid(4).

lv_dat2 = s_supervisor1-expid+4(2).

CONCATENATE lv_dat2

s_supervisor1-expid+6(2)

lv_dat1

INTO lv_dat3 SEPARATED BY '/'.

CLEAR: s_objbin, lv_mail.

CONCATENATE text-007 lv_dat3 INTO lv_mail

SEPARATED BY space.

s_objbin-line = lv_mail.

APPEND s_objbin TO it_objbin.

CLEAR: s_objbin, lv_mail.

CONCATENATE text-008

s_supervisor1-psename

text-009 INTO lv_mail SEPARATED BY space.

s_objbin-line = lv_mail.

APPEND s_objbin TO it_objbin.

CLEAR s_objbin.

s_objbin-line = text-010.

APPEND s_objbin TO it_objbin.

Sending Of Email

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = s_doc_chng

document_type = 'BIN'

put_in_outbox = 'X'

TABLES

object_content = it_objbin

receivers = it_reclist

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 ne 0.

message I001(00) with text-I05.

Mail Not Sent

exit.

ENDIF.

ENDLOOP.

Helpful answers will be awarded with good points

4 REPLIES 4

Former Member
0 Kudos

Hi

If you check in SOST tcode, you can find your mail in the queue. Add the following lines to your code. These two statements are used to force the mail to send it to the receipeint otherwise we need to go to SOST tcode where we need to press F8 to send the mail to the other user. To avoid this we need to use these two statements. Here the mail is not in queue.


IF sy-subrc EQ 0.

  submit rsconn01 using selection-set 'INT' and return.
  call function 'SO_DEQUEUE_UPDATE_LOCKS'.

ELSE.

 MESSAGE 'Mail not sent' type 'S'

ENDIF.

Regards

Indu

Former Member
0 Kudos

Hi,

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = s_doc_chng

document_type = 'BIN'

put_in_outbox = 'X'

commit_work = 'X'

TABLES

object_content = it_objbin

receivers = it_reclist

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.

Add

commit_work = 'X'

Thanks,

Durai.V

Former Member
0 Kudos

Hi

Good,

Check this forum link, hope this will give you the idea to solve your problem

Thanks

mrutyun^

arpit_shah
Contributor
0 Kudos

Hi,

put this code at end of your code,

wait up to 5 seconds.

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

just call RSCONN01 at end of your code.

Regards,

Arpit