메뉴 건너뛰기

SAP 한국 커뮤니티

Email 전송 Sample

양키(이경환) 2014.03.12 10:25 조회 수 : 6769

  REPORT  z_test_email.
DATA:
  subject               TYPE so_obj_des,
  it_body_text         TYPE soli_tab,
  it_body_html         TYPE soli_tab,
  from                 TYPE ad_smtpadr,
  to                   TYPE ad_smtpadr.
DATA:
  document             TYPE REF TO cl_document_bcs,
  request              TYPE REF TO cl_bcs,
  mime_helper          TYPE REF TO cl_gbt_multirelated_service,
  sender               TYPE REF TO if_sender_bcs,
  recipient            TYPE REF TO if_recipient_bcs.

to      'receiver@gmail.com'.
from    'sendor@gmail.com'.

subject 'Test Email Data'.
APPEND 'Hello World'           TO it_body_text.
APPEND 'Column 1     Column 2' TO it_body_text.
APPEND 'a            b'        TO it_body_text.
APPEND 'xyz          test'     TO it_body_text.
APPEND '4711         0815'     TO it_body_text.
APPEND '<html>'                      TO it_body_html.
APPEND '<head>'                      TO it_body_html.
APPEND '<title>MY HTML part</title>' TO it_body_html.
APPEND '</head>'                     TO it_body_html.
APPEND '<body>'                      TO it_body_html.
APPEND '<h1>Hello World!</h1>'       TO it_body_html.
APPEND '<table border="1">'          TO it_body_html.
APPEND '<tr><td>Column 1</td><td>Column 2</td></tr>' TO it_body_html.
APPEND '<tr><td>a</td><td>b</td></tr>'               TO it_body_html.
APPEND '<tr><td>xyz</td><td>test</td></tr>'          TO it_body_html.
APPEND '<tr><td>4711</td><td>0815</td></tr>'         TO it_body_html.
APPEND '</table>' TO it_body_html.
APPEND '</body>'  TO it_body_html.
APPEND '</html>'  TO it_body_html.

CREATE OBJECT mime_helper.
mime_helper->set_main_textcontent it_body_text ).
mime_helper->set_main_htmlcontent it_body_html ).
document cl_document_bcs=>create_from_multirelated(
  i_subject          subject
  i_multirel_service mime_helper ).

request cl_bcs=>create_persistent).
request->set_documentdocument ).

IF from IS NOT INITIAL.
  sender cl_cam_address_bcs=>create_internet_addressfrom ).
ELSE.
  sender cl_sapuser_bcs=>createsy-uname ).
ENDIF.

request->set_sendersender ).
recipient cl_cam_address_bcs=>create_internet_addressto ).
request->add_recipientEXPORTING i_recipient recipient ).
request->set_send_immediately'X' ).

IF request->sendi_with_error_screen 'X' 'X'.
  WRITE:'Email sent succesfully'.
ELSE.
  WRITE:' Error sending email'.
ENDIF.
COMMIT WORK.
번호 제목 글쓴이 날짜 조회 수
487 ALV 동적 필드 구성 [4] 꿀홍삼 2015.02.06 9550
486 SUBQUERY 사용예 입니다. [1] 노름마치 2007.11.20 9539
485 Open SQL에서 SUM 사용시 유의사항. [11] 나침반친구 2007.06.07 9539
484 간단한 계산공식은 Macro를 사용하자 [5] 양키 2011.04.14 9532
483 Field Catalog 가져오지 못하는문제(REUSE_ALV_FIELDCATALOG_MERGE) [3] 양키 2013.08.16 9485
482 sap 메뉴에서 표준 매뉴 전환 [1] selection장 2013.09.13 9445
481 FIELD-SYMBOL설명 및 예제 프로그램 [17] Delight 2008.04.30 9426
480 <img src=d.gif>Source Activation 시 [READ_REPORT_LINE_TOO_LONG] dump 발생하면?[추천:e-abap] [5] JYG 2011.02.11 9417
479 테이블컨트롤에서 F4 값 변경시 다른 필드 값도 변경하기 F4IF_INT_TABLE_VALUE_REQUEST [1] 한해동안 2008.07.24 9406
478 표준편차구하는 로직 윤사모 2011.03.23 9369
477 BAPI_MATERIAL_SAVEDATA 자재마스터 생성시에 사용하세요. [1] 노름마치 2007.12.10 9239
476 SAP 단순하지만, 모르면 정말 불편 한 기능들 [22] SARA 2007.03.27 9217
475 TYPE-1 프로그램에서 실행버튼 없애기 [1] 아밥뽀 2013.09.23 9109
474 엑셀에서 '-' 부호 앞으로 옮기기 [18] file MasFI 2013.02.08 8990
473 SELECT-OPTIONS 문법 [5] sapjoy 2006.12.28 8978
472 ALV 내용 변경 방법. [8] 초보보초보 2007.02.07 8928
471 SAP GUI 730 ALV Grid 느림 현상(해결방법) [3] Dave 2013.09.27 8883
470 효과적인 ABAP/4 프로그램 작성기법 [24] 열공아밥 2009.12.20 8878
469 유용한 t-code 모음들 [26] 아이디빵 2008.04.24 8795
468 where 조건을 상황에따라 바꿔볼까? [8] 양키 2011.04.14 8738