SDK for SAP ABAP를 사용한 Amazon SES API v2 예제 - AWS SDK 코드 예제

Doc AWS SDK 예제 GitHub 리포지토리에서 더 많은 SDK 예제를 사용할 수 있습니다. AWS

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

SDK for SAP ABAP를 사용한 Amazon SES API v2 예제

다음 코드 예제에서는 Amazon SES API v2와 함께 AWS SDK for SAP ABAP를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

주제

작업

다음 코드 예시는 CreateContact의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->createcontact( iv_contactlistname = iv_contact_list_name iv_emailaddress = iv_email_address ). MESSAGE 'Contact created successfully.' TYPE 'I'. CATCH /aws1/cx_se2alreadyexistsex. MESSAGE 'Contact already exists.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex. MESSAGE 'Bad request.' TYPE 'E'. CATCH /aws1/cx_se2notfoundexception. MESSAGE 'Contact list not found.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조CreateContact를 참조하세요.

다음 코드 예시는 CreateContactList의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->createcontactlist( iv_contactlistname = iv_contact_list_name ). MESSAGE 'Contact list created successfully.' TYPE 'I'. CATCH /aws1/cx_se2alreadyexistsex. MESSAGE 'Contact list already exists.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request - contact list limit may be reached.' TYPE 'I'. " Re-raise the exception so the caller can handle it RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_se2limitexceededex INTO DATA(lo_limit_exceeded). MESSAGE 'Limit exceeded - contact list limit reached.' TYPE 'I'. " Re-raise the exception so the caller can handle it RAISE EXCEPTION lo_limit_exceeded. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조CreateContactList를 참조하세요.

다음 코드 예시는 CreateEmailIdentity의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->createemailidentity( iv_emailidentity = iv_email_identity ). MESSAGE 'Email identity created successfully.' TYPE 'I'. CATCH /aws1/cx_se2alreadyexistsex. MESSAGE 'Email identity already exists.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request TYPE 'I' DISPLAY LIKE 'E'. CATCH /aws1/cx_se2limitexceededex INTO DATA(lo_limit_exceeded). MESSAGE lo_limit_exceeded TYPE 'I' DISPLAY LIKE 'E'. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 CreateEmailIdentity를 참조하세요. AWS

다음 코드 예시는 CreateEmailTemplate의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. DATA(lo_template_content) = NEW /aws1/cl_se2emailtmplcontent( iv_subject = iv_subject iv_html = iv_html iv_text = iv_text ). lo_se2->createemailtemplate( iv_templatename = iv_template_name io_templatecontent = lo_template_content ). MESSAGE 'Email template created successfully.' TYPE 'I'. CATCH /aws1/cx_se2alreadyexistsex. MESSAGE 'Email template already exists.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex. MESSAGE 'Bad request.' TYPE 'E'. CATCH /aws1/cx_se2limitexceededex. MESSAGE 'Limit exceeded.' TYPE 'E'. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 CreateEmailTemplate을 참조하세요. AWS

다음 코드 예시는 DeleteContactList의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->deletecontactlist( iv_contactlistname = iv_contact_list_name ). MESSAGE 'Contact list deleted successfully.' TYPE 'I'. CATCH /aws1/cx_se2notfoundexception. MESSAGE 'Contact list not found.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 DeleteContactList를 참조하세요. AWS

다음 코드 예시는 DeleteEmailIdentity의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->deleteemailidentity( iv_emailidentity = iv_email_identity ). MESSAGE 'Email identity deleted successfully.' TYPE 'I'. CATCH /aws1/cx_se2notfoundexception. MESSAGE 'Email identity not found.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 DeleteEmailIdentity를 참조하세요. AWS

다음 코드 예시는 DeleteEmailTemplate의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. lo_se2->deleteemailtemplate( iv_templatename = iv_template_name ). MESSAGE 'Email template deleted successfully.' TYPE 'I'. CATCH /aws1/cx_se2notfoundexception. MESSAGE 'Email template not found.' TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. ENDTRY.
  • API 세부 정보는 SDK for SAP ABAP API 참조의 DeleteEmailTemplate을 참조하세요. AWS

다음 코드 예시는 ListContacts의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

TRY. oo_result = lo_se2->listcontacts( iv_contactlistname = iv_contact_list_name ). DATA(lv_count) = lines( oo_result->get_contacts( ) ). MESSAGE |Retrieved { lv_count } contacts from list.| TYPE 'I'. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_se2notfoundexception INTO DATA(lo_not_found). MESSAGE 'Contact list not found.' TYPE 'I'. RAISE EXCEPTION lo_not_found. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조ListContacts를 참조하세요.

다음 코드 예시는 SendEmail의 사용 방법을 보여 줍니다.

SDK for SAP ABAP API
참고

GitHub에 더 많은 내용이 있습니다. AWS 코드 예 리포지토리에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요.

메시지를 전송합니다.

TRY. " Create destination with recipient address DATA lt_to_addresses TYPE /aws1/cl_se2emailaddresslist_w=>tt_emailaddresslist. APPEND NEW /aws1/cl_se2emailaddresslist_w( iv_value = iv_to_email_address ) TO lt_to_addresses. DATA(lo_destination) = NEW /aws1/cl_se2destination( it_toaddresses = lt_to_addresses ). " Create message content DATA(lo_subject) = NEW /aws1/cl_se2content( iv_data = iv_subject ). DATA(lo_text_body) = NEW /aws1/cl_se2content( iv_data = iv_text_body ). DATA(lo_html_body) = NEW /aws1/cl_se2content( iv_data = iv_html_body ). DATA(lo_body) = NEW /aws1/cl_se2body( io_text = lo_text_body io_html = lo_html_body ). DATA(lo_message) = NEW /aws1/cl_se2message( io_subject = lo_subject io_body = lo_body ). DATA(lo_content) = NEW /aws1/cl_se2emailcontent( io_simple = lo_message ). " Send the email lo_se2->sendemail( iv_fromemailaddress = iv_from_email_address io_destination = lo_destination io_content = lo_content ). MESSAGE 'Email sent successfully.' TYPE 'I'. CATCH /aws1/cx_se2accountsuspendedex INTO DATA(lo_account_suspended). MESSAGE 'Account suspended.' TYPE 'I'. RAISE EXCEPTION lo_account_suspended. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_se2messagerejected INTO DATA(lo_message_rejected). MESSAGE 'Message rejected - check email verification.' TYPE 'I'. RAISE EXCEPTION lo_message_rejected. ENDTRY.

템플릿을 사용하여 메시지를 보냅니다.

TRY. " Create destination with recipient address DATA lt_to_addresses TYPE /aws1/cl_se2emailaddresslist_w=>tt_emailaddresslist. APPEND NEW /aws1/cl_se2emailaddresslist_w( iv_value = iv_to_email_address ) TO lt_to_addresses. DATA(lo_destination) = NEW /aws1/cl_se2destination( it_toaddresses = lt_to_addresses ). " Create template reference DATA(lo_template) = NEW /aws1/cl_se2template( iv_templatename = iv_template_name iv_templatedata = iv_template_data ). DATA(lo_content) = NEW /aws1/cl_se2emailcontent( io_template = lo_template ). " Create list management options DATA(lo_list_mgmt) = NEW /aws1/cl_se2listmanagementopts( iv_contactlistname = iv_contact_list_name ). " Send the email using template lo_se2->sendemail( iv_fromemailaddress = iv_from_email_address io_destination = lo_destination io_content = lo_content io_listmanagementoptions = lo_list_mgmt ). MESSAGE 'Email sent using template successfully.' TYPE 'I'. CATCH /aws1/cx_se2accountsuspendedex INTO DATA(lo_account_suspended). MESSAGE 'Account suspended.' TYPE 'I'. RAISE EXCEPTION lo_account_suspended. CATCH /aws1/cx_se2badrequestex INTO DATA(lo_bad_request). MESSAGE 'Bad request.' TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_se2messagerejected INTO DATA(lo_message_rejected). MESSAGE 'Message rejected - check email verification.' TYPE 'I'. RAISE EXCEPTION lo_message_rejected. ENDTRY.
  • API 세부 정보는 AWS SDK for SAP ABAP API 참조SendEmail을 참조하세요.