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 trigger mails through ABAP Code

0 Likes
814

Hi,

Is it possible to send mails through ABAP code? Are there any classes FMs? Please suggest.

Thanks & Regards,

Saurabh

7 REPLIES 7
Read only

Former Member
Read only

Former Member
0 Likes
783

Sending a 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 = 'someone@somewhere.com'.

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.

Read only

Former Member
0 Likes
783

Check the FM SO_NEW_DOCUMENT_SEND_API1

Read only

Former Member
0 Likes
783

SO_NEW_DOCUMENT_ATT_SEND_API1 SAPoffice: Send new document with attachments using RFC

SO_NEW_DOCUMENT_SEND_API1 SAPoffice: Send new document

Read only

Former Member
0 Likes
783

CL_SOTR_SEND_MAIL "for sending and editing mail

EFG_GEN_SEND_EMAIL "FM to sedn mail

regards

Read only

Former Member
0 Likes
783

SAP Send mail via ABAP functions SO_NEW_DOCUMENT_SEND_API1

See <a href="http://www.atomhr.com/know_preview/abap_to_send_mail.htm">Sending mail</a>

Read only

Former Member
0 Likes
783

Hi

The ABAP code to send a sap mail is built around the FM SO_OBJECT_SEND which has the following pattern.

call function 'SO_OBJECT_SEND'

exporting

  • EXTERN_ADDRESS = ' '

  • FOLDER_ID = ' '

  • FORWARDER = ' '

  • OBJECT_FL_CHANGE = ' '

  • OBJECT_HD_CHANGE = ' '

  • OBJECT_ID = ' '

  • OBJECT_TYPE = ' '

  • OUTBOX_FLAG = ' '

  • OWNER = ' '

  • STORE_FLAG = ' '

  • DELETE_FLAG = ' '

  • SENDER = ' '

  • CHECK_ALREADY_SENT = ' '

importing

object_id_new =

sent_to_all =

tables

  • OBJCONT =

  • OBJHEAD =

  • OBJPARA =

  • OBJPARB =

receivers =

  • PACKING_LIST =

  • ATT_CONT =

  • ATT_HEAD =

  • NOTE_TEXT =

exceptions

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

x_error = 20

others = 21.