SCOT에서 SMTP설정하고
메일 발송하는거 해보는데 안되서요.
1. SMTP에서 설정이 되서 연결이 되는지 어떻게 알수 있을까요?
2. ZIF_SEND_EMAIL 펑션프로그램을 사용하는데 테스트런시
오류는 없는데 메일 발송이 안되고 있는데..
원인을 아시거나 소스중에 SMTP설정후 실행하면 메일 발송되는
소스있으신분 부탁드립니다.
** 최종적으로 내가 구현하고 싶은건 PR리스트를 PDF로 만들어서 화일로
거래처에 메일을 발송하고 싶습니다.
도움되는 글이나 문서 부탁드립니다.
제가 뭘 더 해야 하는데 안한건지...경험이 없다보니 힘들군요.
FUNCTION ZIF_SEND_EMAIL.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(TITLE)
*" REFERENCE(ADDRESS)
*" TABLES
*" BODY
*" ATTACH
*"----------------------------------------------------------------------
DATA : E_MAIL(30),
DOC_SIZE(12) TYPE N,
BODY_LINES LIKE SY-TABIX,
ATTACH_LINES LIKE SY-TABIX.
DATA :
DOCUMENT_DATA LIKE SODOCCHGI1,
PACKING_LIST LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
OBJECT_HEADER LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
CONTENTS_BIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
CONTENTS_TXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
RECEIVERS LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
*// 메일주소
MOVE ADDRESS TO E_MAIL.
TRANSLATE E_MAIL TO LOWER CASE.
RECEIVERS-RECEIVER = ADDRESS.
RECEIVERS-REC_TYPE = 'U'.
RECEIVERS-EXPRESS = 'X'.
RECEIVERS-COM_TYPE = 'INT' .
APPEND RECEIVERS. CLEAR RECEIVERS.
*// 본문
LOOP AT BODY.
MOVE BODY TO CONTENTS_TXT-LINE.
APPEND CONTENTS_TXT. CLEAR CONTENTS_TXT.
ENDLOOP.
DESCRIBE TABLE CONTENTS_TXT LINES BODY_LINES.
READ TABLE CONTENTS_TXT INDEX BODY_LINES.
DOCUMENT_DATA-DOC_SIZE
= ( BODY_LINES - 1 ) * 255 + STRLEN( CONTENTS_TXT ).
*// 메일제목
DOCUMENT_DATA-OBJ_NAME = 'URGENT'.
DOCUMENT_DATA-SENSITIVTY = 'P'.
DOCUMENT_DATA-OBJ_LANGU = 'E'.
DOCUMENT_DATA-OBJ_PRIO = '1'.
DOCUMENT_DATA-NO_CHANGE = 'X'.
DOCUMENT_DATA-PRIORITY = '1'.
DOCUMENT_DATA-OBJ_DESCR = TITLE.
* Fill the fields of the packing_list for the main
* It is a text document
CLEAR PACKING_LIST-TRANSF_BIN.
PACKING_LIST-HEAD_START = 1.
PACKING_LIST-HEAD_NUM = 0.
PACKING_LIST-BODY_START = 1.
PACKING_LIST-BODY_NUM = BODY_LINES.
PACKING_LIST-DOC_TYPE = 'TXT'.
APPEND PACKING_LIST.
*// 첨부파일
LOOP AT ATTACH.
MOVE ATTACH TO CONTENTS_BIN-LINE.
APPEND CONTENTS_BIN. CLEAR CONTENTS_BIN.
ENDLOOP.
* Create the attachment (the list itself)
DESCRIBE TABLE CONTENTS_BIN LINES ATTACH_LINES.
* Fill the fields of the packing_list for the attachment:
* It is binary document
PACKING_LIST-TRANSF_BIN = 'X'.
* we need no header
PACKING_LIST-HEAD_START = 1.
PACKING_LIST-HEAD_NUM = 0.
* but a body
PACKING_LIST-BODY_START = 1.
PACKING_LIST-BODY_NUM = ATTACH_LINES.
* of type ALI
PACKING_LIST-DOC_TYPE = 'TXT'.
PACKING_LIST-OBJ_NAME = 'Attachment'.
PACKING_LIST-OBJ_DESCR = '첨부파일'.
READ TABLE CONTENTS_BIN INDEX ATTACH_LINES.
DOC_SIZE = ( ATTACH_LINES - 1 ) * 255 + STRLEN( CONTENTS_BIN ).
PACKING_LIST-DOC_SIZE = DOC_SIZE.
APPEND PACKING_LIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOCUMENT_DATA
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = PACKING_LIST
OBJECT_HEADER = OBJECT_HEADER
CONTENTS_BIN = CONTENTS_BIN
CONTENTS_TXT = CONTENTS_TXT
RECEIVERS = RECEIVERS
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
OPERATION_NO_AUTHORIZATION = 4
OTHERS = 99.
ENDFUNCTION.