05/08/2010

Simple Email Sending Program



REPORT ZRRSAMPLE.

*----------------------------------------------------------*
*Description: this report will creates an output in email
* in HTML format
*----------------------------------------------------------*

DATA: it_maildata TYPE sodocchgi1 OCCURS 10 WITH HEADER LINE ,
it_mailtext LIKE solisti1 OCCURS 10 WITH HEADER LINE,
it_mailrecep LIKE somlrec90 OCCURS 10 WITH HEADER LINE,
it_listtable TYPE abaplist OCCURS 10 WITH HEADER LINE,
it_htmldata TYPE w3html OCCURS 10 WITH HEADER LINE,
it_ascidatatab TYPE char255 OCCURS 10 WITH HEADER LINE.


START-OF-SELECTION.
*----------------------------------------------------------*
**before submitting the report first create a test program for
**displaying the output in html program .copy and paste the
**below report
*report ztest_submit.
*start-of-selection.
*do 10 times.
*write:/ 'this is the test report for html output in email'.
*enddo.
*----------------------------------------------------------*

SUBMIT ztest_submit
EXPORTING LIST TO MEMORY AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = it_listtable
EXCEPTIONS
not_found = 1
OTHERS = 2.

CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
TABLES
html = it_htmldata
listobject = it_listtable.


CLEAR: it_maildata,
it_mailtext,
it_mailrecep.

REFRESH: it_mailtext,
it_mailrecep.

it_maildata-obj_name = 'TEST'.
it_maildata-obj_descr = 'RR TEST SUBJECT'.

LOOP AT it_htmldata.

it_mailtext = it_htmldata.

APPEND it_mailtext.

ENDLOOP.

it_mailrecep-receiver = 'teste@gmail.com'.
it_mailrecep-rec_type = 'U'.

APPEND it_mailrecep.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = it_maildata
document_type = 'HTM'
put_in_outbox = 'X'
TABLES
object_header = it_mailtext
object_content = it_mailtext
receivers = it_mailrecep
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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

COMMIT WORK.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.

Nenhum comentário:

Postar um comentário