AWS SDK 또는 UpdateTemplate CLI와 함께 사용 - Amazon Simple Email Service

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

AWS SDK 또는 UpdateTemplate CLI와 함께 사용

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

작업 예제는 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 다음 코드 예제에서는 컨텍스트 내에서 이 작업을 확인할 수 있습니다.

C++
SDK for C++
참고

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

//! Update an Amazon Simple Email Service (Amazon SES) template. /*! \param templateName: The name of the template. \param htmlPart: The HTML body of the email. \param subjectPart: The subject line of the email. \param textPart: The plain text version of the email. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::updateTemplate(const Aws::String &templateName, const Aws::String &htmlPart, const Aws::String &subjectPart, const Aws::String &textPart, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::Template templateValues; templateValues.SetTemplateName(templateName); templateValues.SetSubjectPart(subjectPart); templateValues.SetHtmlPart(htmlPart); templateValues.SetTextPart(textPart); Aws::SES::Model::UpdateTemplateRequest updateTemplateRequest; updateTemplateRequest.SetTemplate(templateValues); Aws::SES::Model::UpdateTemplateOutcome outcome = sesClient.UpdateTemplate(updateTemplateRequest); if (outcome.IsSuccess()) { std::cout << "Successfully updated template." << std::endl; } else { std::cerr << "Error updating template. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • API 세부 정보는 AWS SDK for C++ API UpdateTemplate참조를 참조하십시오.

JavaScript
JavaScript (v3) 용 SDK
참고

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

import { UpdateTemplateCommand } from "@aws-sdk/client-ses"; import { getUniqueName } from "@aws-doc-sdk-examples/lib/utils/util-string.js"; import { sesClient } from "./libs/sesClient.js"; const TEMPLATE_NAME = getUniqueName("TemplateName"); const HTML_PART = "<h1>Hello, World!</h1>"; const createUpdateTemplateCommand = () => { return new UpdateTemplateCommand({ Template: { TemplateName: TEMPLATE_NAME, HtmlPart: HTML_PART, SubjectPart: "Example", TextPart: "Updated template text.", }, }); }; const run = async () => { const updateTemplateCommand = createUpdateTemplateCommand(); try { return await sesClient.send(updateTemplateCommand); } catch (err) { console.log("Failed to update template.", err); return err; } };
  • API 세부 정보는 AWS SDK for JavaScript API UpdateTemplate참조를 참조하십시오.

Python
SDK for Python(Boto3)
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

class SesTemplate: """Encapsulates Amazon SES template functions.""" def __init__(self, ses_client): """ :param ses_client: A Boto3 Amazon SES client. """ self.ses_client = ses_client self.template = None self.template_tags = set() def _extract_tags(self, subject, text, html): """ Extracts tags from a template as a set of unique values. :param subject: The subject of the email. :param text: The text version of the email. :param html: The html version of the email. """ self.template_tags = set(re.findall(TEMPLATE_REGEX, subject + text + html)) logger.info("Extracted template tags: %s", self.template_tags) def update_template(self, name, subject, text, html): """ Updates a previously created email template. :param name: The name of the template. :param subject: The subject of the email. :param text: The plain text version of the email. :param html: The HTML version of the email. """ try: template = { "TemplateName": name, "SubjectPart": subject, "TextPart": text, "HtmlPart": html, } self.ses_client.update_template(Template=template) logger.info("Updated template %s.", name) self.template = template self._extract_tags(subject, text, html) except ClientError: logger.exception("Couldn't update template %s.", name) raise
  • API에 대한 자세한 내용은 파이썬용AWS SDK (Boto3) API 레퍼런스를 참조하십시오 UpdateTemplate.

AWS SDK 개발자 가이드 및 코드 예제의 전체 목록은 을 참조하십시오. AWS SDK와 함께 Amazon SES를 사용하기 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.