REPORT z_barry_send_express_mail.
PARAMETERS: p_uname(40) TYPE c DEFAULT 'BAITZ' .
DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gd_sent_all(1) TYPE c,
gd_doc_data LIKE sodocchgi1 .
START-OF-SELECTION.
PERFORM send_email .
*&---------------------------------------------------------------------*
*& Form SEND_EMAIL_MESSAGE
*&---------------------------------------------------------------------*
FORM send_email .
APPEND 'asfasfadsf' TO it_contents.
APPEND 'asfasdfasfafasfa' TO it_contents.
gd_doc_data-obj_langu = sy-langu.
gd_doc_data-obj_descr = '此处填主题'.
CLEAR it_packing_list.
REFRESH it_packing_list.
it_packing_list-transf_bin = space.
it_packing_list-head_start = 1.
it_packing_list-head_num = 0.
it_packing_list-body_start = 1.
DESCRIBE TABLE it_contents LINES it_packing_list-body_num.
it_packing_list-doc_type = 'RAW'.
APPEND it_packing_list.
CLEAR it_receivers.
REFRESH it_receivers.
it_receivers-receiver = p_uname.
it_receivers-rec_type = 'B'.
it_receivers-com_type = 'INT'.
it_receivers-notif_del = 'X'.
it_receivers-notif_ndel = 'X'.
it_receivers-express = 'X'.
APPEND it_receivers.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gd_doc_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = gd_sent_all
TABLES
packing_list = it_packing_list
contents_txt = it_contents
receivers = it_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 <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "send_email
或者使用简单方法,只能发送文本:
REPORT zrs08199 .
DATA: ztext LIKE soli OCCURS 0 WITH HEADER LINE .
PARAMETERS: uname LIKE usr02-bname .
START-OF-SELECTION .
EDITOR-CALL FOR ztext.
CALL FUNCTION 'RS_SEND_MAIL_FOR_SPOOLLIST'
EXPORTING
mailname = 'aaa'
mailtitel = 'bbb'
user = uname
TABLES
text = ztext
EXCEPTIONS
error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
阅读(3586) | 评论(1) | 转发(1) |