概要
アドオンプログラムでメール送信を行うには送信先、送信元、メールタイトル・本文、添付ファイルの
パラメータを汎用モジュール:SO_DOCUMENT_SEND_API1に渡す事で実現可能。
送信元が実行ユーザーでよい場合は汎用モジュール:SO_NEW_DOCUMENT_ATT_SEND_API1でも可能だが、
正直何の違いがあるか不明。
サンプルコード:メール送信
* Sender DATA: v_sender TYPE soextreci1-receiver, v_sender_typ TYPE soextreci1-adr_typ. v_sender = sy-uname. v_sender_typ = 'B'. *v_sender = 'Sender@xxx.com'. *v_sender_typ = 'SMTP'. * Reciever DATA: it_reclist TYPE somlreci1 OCCURS 5 WITH HEADER LINE. it_reclist-receiver = 'Receiver@xxx.com'. it_reclist-rec_type = 'U'. it_reclist-com_type = 'INT'. it_reclist-notif_del = 'X'. it_reclist-notif_ndel = 'X'. it_reclist-express = 'X'. APPEND it_reclist. * E-mail Header DATA: v_doc_data TYPE sodocchgi1. v_doc_data-obj_descr = 'E-mail Title'. * E-mail Body DATA: wa_body TYPE soli, it_body TYPE soli_tab. wa_body = 'E-mail body 1 line'. APPEND wa_body TO it_body. wa_body = 'E-mail body 2 line'. APPEND wa_body TO it_body. DATA: it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE. it_packing_list-transf_bin = space. it_packing_list-head_start = 1. it_packing_list-head_num = 0. it_packing_list-body_start = 1. it_packing_list-doc_type = 'RAW'. DESCRIBE TABLE it_body LINES it_packing_list-body_num. it_packing_list-doc_size = it_packing_list-body_num * 255. APPEND it_packing_list. *Attached file DATA: it_file LIKE solisti1 OCCURS 0 WITH HEADER LINE, it_file_hex TYPE solix_tab, v_filesize TYPE i. it_file = 'Attached file line 1'. APPEND it_file. it_file = 'Attached file line 2'. APPEND it_file. CALL FUNCTION 'SCMS_TEXT_TO_BINARY' IMPORTING output_length = v_filesize TABLES text_tab = it_file binary_tab = it_file_hex EXCEPTIONS failed = 1 OTHERS = 2. it_packing_list-transf_bin = 'X'. it_packing_list-head_start = 1. it_packing_list-head_num = 1. it_packing_list-body_start = 1. it_packing_list-doc_type = 'txt'. it_packing_list-obj_descr = 'filename'. DESCRIBE TABLE it_file_hex LINES it_packing_list-body_num. it_packing_list-doc_size = it_packing_list-body_num * 255. APPEND it_packing_list. * Call Function module CALL FUNCTION 'SO_DOCUMENT_SEND_API1' EXPORTING document_data = v_doc_data sender_address = v_sender sender_address_type = v_sender_typ commit_work = 'X' TABLES packing_list = it_packing_list contents_txt = it_body contents_hex = it_file_hex receivers = it_reclist 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.
説明
document_data:ヘッダ的な情報
sender_address:送信元の情報(ユーザーID、メールアドレス等)
sender_address_type:送信元の情報(ユーザーIDの場合’B’、メールアドレスの場合’SMTP’、他多数有り)
packing_list:本文と添付ファイルの情報
contents_txt:メール本文
contents_hex:添付ファイル
複数送信したい場合は、作りたい文だけpacking_listを追加していけばいけそうだけど未確認
最近のコメント