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: 

Sending email

Former Member
0 Kudos

Hi Friends,

I am working in a module pool requirement in that while uploading a file if any error record is there it should be sent to user as a email.

Please help me how to handle the sending mail part with code.

Thanks & Regards,

Gayathri S

1 REPLY 1

Former Member
0 Kudos

Hi,

SELECT-OPTIONS: dreceiv FOR receivers-receiver NO INTERVALS.

DATA: obj_co LIKE solisti1 OCCURS 1 WITH HEADER LINE .

DATA: lv_ekgrp LIKE ekko-ekgrp,

lv_datum(10).

CLEAR: receivers, receivers[],

document_data,

obj_co, obj_co[].

CHECK pa_mailx = 'X'.

IF NOT imail[] IS INITIAL.

    • Mail-Kopf

document_data-obj_name =

'E: Update WE-Kennzeichen kontierten Bestellungen'.

document_data-obj_descr =

'E: Update WE-Kennzeichen kontierten Bestellungen'.

document_data-obj_langu = 'DE'.

LOOP AT dreceiv.

MOVE dreceiv-low TO receivers-receiver.

receivers-rec_type = 'U'.

APPEND receivers.

ENDLOOP.

WRITE: sy-datum TO lv_datum.

    • System-ID

CONCATENATE 'System:'

sy-sysid

'Datum:'

lv_datum

INTO obj_co-line

SEPARATED BY space.

APPEND obj_co.

LOOP AT imail.

CONCATENATE 'Fehler: '

imail-text

INTO obj_co-line.

APPEND obj_co.

ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

document_data = document_data

document_type = 'RAW'

TABLES

object_content = obj_co

receivers = receivers

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 e918 WITH 'Fehler beim Email-Versand an' receivers-receiver.

ELSE.

MESSAGE s918 WITH 'Email erfolgreich versendet an'

receivers-receiver.

ENDIF.

ENDIF.

regards

Nicole