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 automatically

0 Likes
7,563

Hello Experts,

I want to send email automatically through ABAP program. I can see those mails in SOST tcode. Everytime I used to execute mails manually in SOST & then they are delivered to respective recipient.

Is there any method that can send mails automatically without using SOST tcode ?

Thanks in advance,

Swanand

1 ACCEPTED SOLUTION
Read only

former_member201275
Active Contributor
0 Likes
5,439

Searching on the net, I've found this piece of code that could help:.

DATA: send_request TYPE REF TO cl_bcs.

send_request = cl_bcs=>create_persistent( ).

... here goes your code.

* Set that you don't need a Return Status E-mail

DATA: status_mail TYPE bcs_stml.

status_mail = 'N'.

CALL METHOD send_request->set_status_attributes

EXPORTING

i_requested_status = status_mail

i_status_mail = status_mail.

* set send immediately flag

send_request->set_send_immediately( 'X' ).

* Send document

CALL METHOD send_request->send( ).

Hello Experts,

I want to send email automatically through ABAP program. I can see those mails in SOST tcode. Everytime I used to execute mails manually in SOST & then they are delivered to respective recipient.

Is there any method that can send mails automatically without using SOST tcode ?

Thanks in advance,

Swanand

5 REPLIES 5
Read only

former_member201275
Active Contributor
0 Likes
5,440

Searching on the net, I've found this piece of code that could help:.

DATA: send_request TYPE REF TO cl_bcs.

send_request = cl_bcs=>create_persistent( ).

... here goes your code.

* Set that you don't need a Return Status E-mail

DATA: status_mail TYPE bcs_stml.

status_mail = 'N'.

CALL METHOD send_request->set_status_attributes

EXPORTING

i_requested_status = status_mail

i_status_mail = status_mail.

* set send immediately flag

send_request->set_send_immediately( 'X' ).

* Send document

CALL METHOD send_request->send( ).

Read only

Former Member
0 Likes
5,439

Hi,

i use RSCONN01 like this:

Regards, Dieter

Read only

Former Member
0 Likes
5,439

Hi ,

Pleas try to use RSCONN01  program  as suggested by Dieter.

but  make sure you need to send all  SOST mail trigger either trigger form your program or some one else.

If any mail status is waiting in SOST then you can use above program. it will be clear all wait status for mail.

and you can set job schedule for this program.

Regards,

Prasenjit

Read only

RaymondGiuseppi
Active Contributor
0 Likes
5,439

Either code a call of RSCONN01 in your code, or schedule (or basis schedules) a job thru transaction SCOT.

Regards,

Raymond

Read only

Former Member
0 Likes
5,439

Hi,  You can try using the FM 'SO_NEW_DOCUMENT_SEND_API1', For example:

report ZSEND_MAIL .


data: maildata type sodocchgi1.

data: mailtxt type table of solisti1 with header line.

data: mailrec type table of somlrec90 with header line.

start-of-selection.

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.

mailrec-receiver = '[email protected]'.

mailrec-rec_type = 'U'.

append mailrec.

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.

if sy-subrc <> 0.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.


I hope this helps you.


Regards.