As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.
Exemplos do Amazon SES usando SDK para SAP ABAP
Os exemplos de código a seguir mostram como realizar ações e implementar cenários comuns usando o AWS SDK para SAP ABAP com o Amazon SES.
Ações são trechos de código de programas maiores e devem ser executadas em contexto. Embora as ações mostrem como chamar perfis de serviço individuais, você pode ver as ações no contexto em seus cenários relacionados.
Cada exemplo inclui um link para o código-fonte completo, em que você pode encontrar instruções sobre como configurar e executar o código.
Tópicos
Ações
O código de exemplo a seguir mostra como usar CreateReceiptFilter.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. " iv_allow = abap_true means 'Allow', abap_false means 'Block' DATA(lv_policy) = COND /aws1/sesreceiptfilterpolicy( WHEN iv_allow = abap_true THEN 'Allow' ELSE 'Block' ). DATA(lo_ip_filter) = NEW /aws1/cl_sesreceiptipfilter( iv_policy = lv_policy iv_cidr = iv_ip_address_or_range ). DATA(lo_filter) = NEW /aws1/cl_sesreceiptfilter( iv_name = iv_filter_name io_ipfilter = lo_ip_filter ). TRY. lo_ses->createreceiptfilter( io_filter = lo_filter ). MESSAGE 'Receipt filter created successfully' TYPE 'I'. CATCH /aws1/cx_sesalreadyexistsex INTO DATA(lo_ex1). DATA(lv_error) = |Filter already exists: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a CreateReceiptFilterreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar CreateReceiptRule.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. " Create S3 action for copying emails to S3 DATA(lo_s3_action) = NEW /aws1/cl_sess3action( iv_bucketname = iv_bucket_name iv_objectkeyprefix = iv_prefix ). " Create receipt action with S3 action DATA(lo_action) = NEW /aws1/cl_sesreceiptaction( io_s3action = lo_s3_action ). " Create list of actions DATA lt_actions TYPE /aws1/cl_sesreceiptaction=>tt_receiptactionslist. APPEND lo_action TO lt_actions. " Create receipt rule DATA(lo_rule) = NEW /aws1/cl_sesreceiptrule( iv_name = iv_rule_name iv_enabled = abap_true it_recipients = it_recipients it_actions = lt_actions ). TRY. lo_ses->createreceiptrule( iv_rulesetname = iv_rule_set_name io_rule = lo_rule ). MESSAGE 'Receipt rule created successfully' TYPE 'I'. CATCH /aws1/cx_sesinvalids3confex INTO DATA(lo_ex1). DATA(lv_error) = |Invalid S3 configuration: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a CreateReceiptRulereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar CreateReceiptRuleSet.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->createreceiptruleset( iv_rulesetname = iv_rule_set_name ). MESSAGE 'Receipt rule set created successfully' TYPE 'I'. CATCH /aws1/cx_sesalreadyexistsex INTO DATA(lo_ex1). DATA(lv_error) = |Rule set already exists: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a CreateReceiptRuleSetreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar CreateTemplate.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. DATA(lo_template) = NEW /aws1/cl_sestemplate( iv_templatename = iv_name iv_subjectpart = iv_subject iv_textpart = iv_text iv_htmlpart = iv_html ). TRY. lo_ses->createtemplate( io_template = lo_template ). MESSAGE 'Template created successfully' TYPE 'I'. CATCH /aws1/cx_sesalreadyexistsex INTO DATA(lo_ex1). DATA(lv_error) = |Template already exists: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_sesinvalidtemplateex INTO DATA(lo_ex2). lv_error = |Invalid template: { lo_ex2->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex2. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a CreateTemplatereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteIdentity.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->deleteidentity( iv_identity = iv_identity ). MESSAGE 'Identity deleted successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a DeleteIdentityreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteReceiptFilter.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->deletereceiptfilter( iv_filtername = iv_filter_name ). MESSAGE 'Receipt filter deleted successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a DeleteReceiptFilterreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteReceiptRule.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->deletereceiptrule( iv_rulesetname = iv_rule_set_name iv_rulename = iv_rule_name ). MESSAGE 'Receipt rule deleted successfully' TYPE 'I'. CATCH /aws1/cx_sesrulesetdoesnotexex INTO DATA(lo_ex1). DATA(lv_error) = |Rule set does not exist: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a DeleteReceiptRulereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteReceiptRuleSet.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->deletereceiptruleset( iv_rulesetname = iv_rule_set_name ). MESSAGE 'Receipt rule set deleted successfully' TYPE 'I'. CATCH /aws1/cx_sescannotdeleteex INTO DATA(lo_ex1). DATA(lv_error) = |Cannot delete rule set: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a DeleteReceiptRuleSetreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DeleteTemplate.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->deletetemplate( iv_templatename = iv_template_name ). MESSAGE 'Template deleted successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a DeleteTemplatereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar DescribeReceiptRuleSet.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. oo_result = lo_ses->describereceiptruleset( iv_rulesetname = iv_rule_set_name ). MESSAGE 'Receipt rule set described successfully' TYPE 'I'. CATCH /aws1/cx_sesrulesetdoesnotexex INTO DATA(lo_ex1). DATA(lv_error) = |Rule set does not exist: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a DescribeReceiptRuleSetreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetIdentityVerificationAttributes.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. DATA lt_identities TYPE /aws1/cl_sesidentitylist_w=>tt_identitylist. APPEND NEW /aws1/cl_sesidentitylist_w( iv_value = iv_identity ) TO lt_identities. TRY. DATA(lo_result) = lo_ses->getidentityverificationattrs( it_identities = lt_identities ). DATA(lt_attrs) = lo_result->get_verificationattributes( ). IF lt_attrs IS NOT INITIAL. LOOP AT lt_attrs ASSIGNING FIELD-SYMBOL(<ls_attr>). ov_status = <ls_attr>-value->get_verificationstatus( ). EXIT. ENDLOOP. ELSE. ov_status = 'NotFound'. ENDIF. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a GetIdentityVerificationAttributesreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar GetTemplate.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ses->gettemplate( iv_templatename = iv_template_name ). oo_template = lo_result->get_template( ). MESSAGE 'Template retrieved successfully' TYPE 'I'. CATCH /aws1/cx_sestmpldoesnotexistex INTO DATA(lo_ex1). DATA(lv_error) = |Template does not exist: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a GetTemplatereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar ListIdentities.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ses->listidentities( iv_identitytype = iv_identity_type iv_maxitems = iv_max_items ). ot_identities = lo_result->get_identities( ). MESSAGE 'Identities retrieved successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a ListIdentitiesreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar ListReceiptFilters.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ses->listreceiptfilters( ). ot_filters = lo_result->get_filters( ). MESSAGE 'Receipt filters retrieved successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a ListReceiptFiltersreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar ListTemplates.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ses->listtemplates( iv_maxitems = iv_max_items ). ot_templates = lo_result->get_templatesmetadata( ). MESSAGE 'Templates retrieved successfully' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a ListTemplatesreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar SendEmail.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. " Create message object DATA(lo_subject) = NEW /aws1/cl_sescontent( iv_data = iv_subject ). DATA(lo_text_body) = NEW /aws1/cl_sescontent( iv_data = iv_text ). DATA(lo_html_body) = NEW /aws1/cl_sescontent( iv_data = iv_html ). DATA(lo_body) = NEW /aws1/cl_sesbody( io_text = lo_text_body io_html = lo_html_body ). DATA(lo_message) = NEW /aws1/cl_sesmessage( io_subject = lo_subject io_body = lo_body ). TRY. " Send email DATA(lo_result) = lo_ses->sendemail( iv_source = iv_source io_destination = io_destination io_message = lo_message it_replytoaddresses = it_reply_tos ). ov_msg_id = lo_result->get_messageid( ). MESSAGE 'Email sent successfully' TYPE 'I'. CATCH /aws1/cx_sesacctsendingpause00 INTO DATA(lo_ex1). DATA(lv_error) = |Account sending paused: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_sesmessagerejected INTO DATA(lo_ex2). lv_error = |Message rejected: { lo_ex2->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex2. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a SendEmailreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar SendTemplatedEmail.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. " Send templated email DATA(lo_result) = lo_ses->sendtemplatedemail( iv_source = iv_source io_destination = io_destination iv_template = iv_template_name iv_templatedata = iv_template_data it_replytoaddresses = it_reply_tos ). ov_msg_id = lo_result->get_messageid( ). MESSAGE 'Templated email sent successfully' TYPE 'I'. CATCH /aws1/cx_sestmpldoesnotexistex INTO DATA(lo_ex1). DATA(lv_error) = |Template does not exist: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a SendTemplatedEmailreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar UpdateTemplate.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. DATA(lo_template) = NEW /aws1/cl_sestemplate( iv_templatename = iv_name iv_subjectpart = iv_subject iv_textpart = iv_text iv_htmlpart = iv_html ). TRY. lo_ses->updatetemplate( io_template = lo_template ). MESSAGE 'Template updated successfully' TYPE 'I'. CATCH /aws1/cx_sestmpldoesnotexistex INTO DATA(lo_ex1). DATA(lv_error) = |Template does not exist: { lo_ex1->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex1. CATCH /aws1/cx_sesinvalidtemplateex INTO DATA(lo_ex2). lv_error = |Invalid template: { lo_ex2->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex2. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex_generic). lv_error = |An error occurred: { lo_ex_generic->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex_generic. ENDTRY.-
Para obter detalhes da API, consulte a UpdateTemplatereferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar VerifyDomainIdentity.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. DATA(lo_result) = lo_ses->verifydomainidentity( iv_domain = iv_domain_name ). ov_token = lo_result->get_verificationtoken( ). MESSAGE 'Domain verification initiated' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a VerifyDomainIdentityreferência da API AWS SDK for SAP ABAP.
-
O código de exemplo a seguir mostra como usar VerifyEmailIdentity.
- SDK para SAP ABAP
-
nota
Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository
. TRY. lo_ses->verifyemailidentity( iv_emailaddress = iv_email_address ). MESSAGE 'Email verification initiated' TYPE 'I'. CATCH /aws1/cx_rt_generic INTO DATA(lo_ex). DATA(lv_error) = |An error occurred: { lo_ex->get_text( ) }|. MESSAGE lv_error TYPE 'I'. RAISE EXCEPTION lo_ex. ENDTRY.-
Para obter detalhes da API, consulte a VerifyEmailIdentityreferência da API AWS SDK for SAP ABAP.
-