Skip to Content

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

Function Module For Sending Mail

Hi Experts,

Is there any function module to send a mail from the ABAP program.

My requirement is to run a report and send the content of the an Internal table as mail.

Thanks in Advance

Tags:
Former Member
Former Member replied

Hi,

u can use the following FM's

1) <b>SO_NEW_DOCUMENT_ATT_SEND_API1</b>(Send new document with attachments)

2) <b>SO_NEW_DOCUMENT_SEND_API1</b>(Send new document with out attachment)

This is a small program which is used for sending mail.

data : maildata type SODOCCHGI1.

data : mailtxt type table of SOLISTI1 with header line.

data : mailrec type table of SOMLRECI1 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 mail'.

append mailtxt.

mailrec-receiver = 'mailid@gmail.com'.

mailrec-rec_type = 'U'.

append mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = maildata

DOCUMENT_TYPE = 'RAW'

PUT_IN_OUTBOX = ' '

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

OBJECT_HEADER = mailtxt

OBJECT_CONTENT = mailtxt

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

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,

Padmam.

0 View this answer in context

Helpful Answer

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