文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的
本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 SES for C++ 的 Amazon SDK 範例
下列程式碼範例示範如何搭配 Amazon SES AWS SDK for C++ 使用 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會示範如何呼叫個別服務函數,但您可以在相關案例中查看內容中的動作。
案例是程式碼範例,示範如何透過呼叫服務內的多個函數或與其他函數結合來完成特定任務 AWS 服務。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
動作
下列程式碼範例示範如何使用 CreateReceiptFilter
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Create an Amazon Simple Email Service (Amazon SES) receipt filter.. /*! \param receiptFilterName: The name for the receipt filter. \param cidr: IP address or IP address range in Classless Inter-Domain Routing (CIDR) notation. \param policy: Block or allow enum of type ReceiptFilterPolicy. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::createReceiptFilter(const Aws::String &receiptFilterName, const Aws::String &cidr, Aws::SES::Model::ReceiptFilterPolicy policy, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::CreateReceiptFilterRequest createReceiptFilterRequest; Aws::SES::Model::ReceiptFilter receiptFilter; Aws::SES::Model::ReceiptIpFilter receiptIpFilter; receiptIpFilter.SetCidr(cidr); receiptIpFilter.SetPolicy(policy); receiptFilter.SetName(receiptFilterName); receiptFilter.SetIpFilter(receiptIpFilter); createReceiptFilterRequest.SetFilter(receiptFilter); Aws::SES::Model::CreateReceiptFilterOutcome createReceiptFilterOutcome = sesClient.CreateReceiptFilter( createReceiptFilterRequest); if (createReceiptFilterOutcome.IsSuccess()) { std::cout << "Successfully created receipt filter." << std::endl; } else { std::cerr << "Error creating receipt filter: " << createReceiptFilterOutcome.GetError().GetMessage() << std::endl; } return createReceiptFilterOutcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 CreateReceiptFilter AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 CreateReceiptRule
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Create an Amazon Simple Email Service (Amazon SES) receipt rule. /*! \param receiptRuleName: The name for the receipt rule. \param s3BucketName: The name of the S3 bucket for incoming mail. \param s3ObjectKeyPrefix: The prefix for the objects in the S3 bucket. \param ruleSetName: The name of the rule set where the receipt rule is added. \param recipients: Aws::Vector of recipients. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::createReceiptRule(const Aws::String &receiptRuleName, const Aws::String &s3BucketName, const Aws::String &s3ObjectKeyPrefix, const Aws::String &ruleSetName, const Aws::Vector<Aws::String> &recipients, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::CreateReceiptRuleRequest createReceiptRuleRequest; Aws::SES::Model::S3Action s3Action; s3Action.SetBucketName(s3BucketName); s3Action.SetObjectKeyPrefix(s3ObjectKeyPrefix); Aws::SES::Model::ReceiptAction receiptAction; receiptAction.SetS3Action(s3Action); Aws::SES::Model::ReceiptRule receiptRule; receiptRule.SetName(receiptRuleName); receiptRule.WithRecipients(recipients); Aws::Vector<Aws::SES::Model::ReceiptAction> receiptActionList; receiptActionList.emplace_back(receiptAction); receiptRule.SetActions(receiptActionList); createReceiptRuleRequest.SetRuleSetName(ruleSetName); createReceiptRuleRequest.SetRule(receiptRule); auto outcome = sesClient.CreateReceiptRule(createReceiptRuleRequest); if (outcome.IsSuccess()) { std::cout << "Successfully created receipt rule." << std::endl; } else { std::cerr << "Error creating receipt rule. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 CreateReceiptRule AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 CreateReceiptRuleSet
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Create an Amazon Simple Email Service (Amazon SES) receipt rule set. /*! \param ruleSetName: The name of the rule set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::createReceiptRuleSet(const Aws::String &ruleSetName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::CreateReceiptRuleSetRequest createReceiptRuleSetRequest; createReceiptRuleSetRequest.SetRuleSetName(ruleSetName); Aws::SES::Model::CreateReceiptRuleSetOutcome outcome = sesClient.CreateReceiptRuleSet( createReceiptRuleSetRequest); if (outcome.IsSuccess()) { std::cout << "Successfully created receipt rule set." << std::endl; } else { std::cerr << "Error creating receipt rule set. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 CreateReceiptRuleSet AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 CreateTemplate
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Create 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::createTemplate(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::CreateTemplateRequest createTemplateRequest; Aws::SES::Model::Template aTemplate; aTemplate.SetTemplateName(templateName); aTemplate.SetHtmlPart(htmlPart); aTemplate.SetSubjectPart(subjectPart); aTemplate.SetTextPart(textPart); createTemplateRequest.SetTemplate(aTemplate); Aws::SES::Model::CreateTemplateOutcome outcome = sesClient.CreateTemplate( createTemplateRequest); if (outcome.IsSuccess()) { std::cout << "Successfully created template." << templateName << "." << std::endl; } else { std::cerr << "Error creating template. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 CreateTemplate AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 DeleteIdentity
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Delete the specified identity (an email address or a domain). /*! \param identity: The identity to delete. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteIdentity(const Aws::String &identity, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteIdentityRequest deleteIdentityRequest; deleteIdentityRequest.SetIdentity(identity); Aws::SES::Model::DeleteIdentityOutcome outcome = sesClient.DeleteIdentity( deleteIdentityRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted identity." << std::endl; } else { std::cerr << "Error deleting identity. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 DeleteIdentity AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 DeleteReceiptFilter
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Delete an Amazon Simple Email Service (Amazon SES) receipt filter. /*! \param receiptFilterName: The name for the receipt filter. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptFilter(const Aws::String &receiptFilterName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptFilterRequest deleteReceiptFilterRequest; deleteReceiptFilterRequest.SetFilterName(receiptFilterName); Aws::SES::Model::DeleteReceiptFilterOutcome outcome = sesClient.DeleteReceiptFilter( deleteReceiptFilterRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt filter." << std::endl; } else { std::cerr << "Error deleting receipt filter. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 DeleteReceiptFilter AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 DeleteReceiptRule
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Delete an Amazon Simple Email Service (Amazon SES) receipt rule. /*! \param receiptRuleName: The name for the receipt rule. \param receiptRuleSetName: The name for the receipt rule set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptRule(const Aws::String &receiptRuleName, const Aws::String &receiptRuleSetName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptRuleRequest deleteReceiptRuleRequest; deleteReceiptRuleRequest.SetRuleName(receiptRuleName); deleteReceiptRuleRequest.SetRuleSetName(receiptRuleSetName); Aws::SES::Model::DeleteReceiptRuleOutcome outcome = sesClient.DeleteReceiptRule( deleteReceiptRuleRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt rule." << std::endl; } else { std::cout << "Error deleting receipt rule. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 DeleteReceiptRule AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 DeleteReceiptRuleSet
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Delete an Amazon Simple Email Service (Amazon SES) receipt rule set. /*! \param receiptRuleSetName: The name for the receipt rule set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptRuleSet(const Aws::String &receiptRuleSetName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptRuleSetRequest deleteReceiptRuleSetRequest; deleteReceiptRuleSetRequest.SetRuleSetName(receiptRuleSetName); Aws::SES::Model::DeleteReceiptRuleSetOutcome outcome = sesClient.DeleteReceiptRuleSet( deleteReceiptRuleSetRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt rule set." << std::endl; } else { std::cerr << "Error deleting receipt rule set. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 DeleteReceiptRuleSet AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 DeleteTemplate
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Delete an Amazon Simple Email Service (Amazon SES) template. /*! \param templateName: The name for the template. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteTemplate(const Aws::String &templateName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteTemplateRequest deleteTemplateRequest; deleteTemplateRequest.SetTemplateName(templateName); Aws::SES::Model::DeleteTemplateOutcome outcome = sesClient.DeleteTemplate( deleteTemplateRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted template." << std::endl; } else { std::cerr << "Error deleting template. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 DeleteTemplate AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 GetTemplate
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Get a template's attributes. /*! \param templateName: The name for the template. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::getTemplate(const Aws::String &templateName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::GetTemplateRequest getTemplateRequest; getTemplateRequest.SetTemplateName(templateName); Aws::SES::Model::GetTemplateOutcome outcome = sesClient.GetTemplate( getTemplateRequest); if (outcome.IsSuccess()) { std::cout << "Successfully got template." << std::endl; } else { std::cerr << "Error getting template. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 GetTemplate AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 ListIdentities
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! List the identities associated with this account. /*! \param identityType: The identity type enum. "NOT_SET" is a valid option. \param identities; A vector to receive the retrieved identities. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::listIdentities(Aws::SES::Model::IdentityType identityType, Aws::Vector<Aws::String> &identities, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::ListIdentitiesRequest listIdentitiesRequest; if (identityType != Aws::SES::Model::IdentityType::NOT_SET) { listIdentitiesRequest.SetIdentityType(identityType); } Aws::String nextToken; // Used for paginated results. do { if (!nextToken.empty()) { listIdentitiesRequest.SetNextToken(nextToken); } Aws::SES::Model::ListIdentitiesOutcome outcome = sesClient.ListIdentities( listIdentitiesRequest); if (outcome.IsSuccess()) { const auto &retrievedIdentities = outcome.GetResult().GetIdentities(); if (!retrievedIdentities.empty()) { identities.insert(identities.cend(), retrievedIdentities.cbegin(), retrievedIdentities.cend()); } nextToken = outcome.GetResult().GetNextToken(); } else { std::cout << "Error listing identities. " << outcome.GetError().GetMessage() << std::endl; return false; } } while (!nextToken.empty()); return true; }
-
如需 API 詳細資訊,請參閱 ListIdentities AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 ListReceiptFilters
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! List the receipt filters associated with this account. /*! \param filters; A vector of "ReceiptFilter" to receive the retrieved filters. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::listReceiptFilters(Aws::Vector<Aws::SES::Model::ReceiptFilter> &filters, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::ListReceiptFiltersRequest listReceiptFiltersRequest; Aws::SES::Model::ListReceiptFiltersOutcome outcome = sesClient.ListReceiptFilters( listReceiptFiltersRequest); if (outcome.IsSuccess()) { auto &retrievedFilters = outcome.GetResult().GetFilters(); if (!retrievedFilters.empty()) { filters.insert(filters.cend(), retrievedFilters.cbegin(), retrievedFilters.cend()); } } else { std::cerr << "Error retrieving IP address filters: " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 ListReceiptFilters AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 SendEmail
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Send an email to a list of recipients. /*! \param recipients; Vector of recipient email addresses. \param subject: Email subject. \param htmlBody: Email body as HTML. At least one body data is required. \param textBody: Email body as plain text. At least one body data is required. \param senderEmailAddress: Email address of sender. Ignored if empty string. \param ccAddresses: Vector of cc addresses. Ignored if empty. \param replyToAddress: Reply to email address. Ignored if empty string. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::sendEmail(const Aws::Vector<Aws::String> &recipients, const Aws::String &subject, const Aws::String &htmlBody, const Aws::String &textBody, const Aws::String &senderEmailAddress, const Aws::Vector<Aws::String> &ccAddresses, const Aws::String &replyToAddress, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::Destination destination; if (!ccAddresses.empty()) { destination.WithCcAddresses(ccAddresses); } if (!recipients.empty()) { destination.WithToAddresses(recipients); } Aws::SES::Model::Body message_body; if (!htmlBody.empty()) { message_body.SetHtml( Aws::SES::Model::Content().WithCharset("UTF-8").WithData(htmlBody)); } if (!textBody.empty()) { message_body.SetText( Aws::SES::Model::Content().WithCharset("UTF-8").WithData(textBody)); } Aws::SES::Model::Message message; message.SetBody(message_body); message.SetSubject( Aws::SES::Model::Content().WithCharset("UTF-8").WithData(subject)); Aws::SES::Model::SendEmailRequest sendEmailRequest; sendEmailRequest.SetDestination(destination); sendEmailRequest.SetMessage(message); if (!senderEmailAddress.empty()) { sendEmailRequest.SetSource(senderEmailAddress); } if (!replyToAddress.empty()) { sendEmailRequest.AddReplyToAddresses(replyToAddress); } auto outcome = sesClient.SendEmail(sendEmailRequest); if (outcome.IsSuccess()) { std::cout << "Successfully sent message with ID " << outcome.GetResult().GetMessageId() << "." << std::endl; } else { std::cerr << "Error sending message. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 SendEmail AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 SendTemplatedEmail
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Send a templated email to a list of recipients. /*! \param recipients; Vector of recipient email addresses. \param templateName: The name of the template to use. \param templateData: Map of key-value pairs for replacing text in template. \param senderEmailAddress: Email address of sender. Ignored if empty string. \param ccAddresses: Vector of cc addresses. Ignored if empty. \param replyToAddress: Reply to email address. Ignored if empty string. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::sendTemplatedEmail(const Aws::Vector<Aws::String> &recipients, const Aws::String &templateName, const Aws::Map<Aws::String, Aws::String> &templateData, const Aws::String &senderEmailAddress, const Aws::Vector<Aws::String> &ccAddresses, const Aws::String &replyToAddress, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::Destination destination; if (!ccAddresses.empty()) { destination.WithCcAddresses(ccAddresses); } if (!recipients.empty()) { destination.WithToAddresses(recipients); } Aws::SES::Model::SendTemplatedEmailRequest sendTemplatedEmailRequest; sendTemplatedEmailRequest.SetDestination(destination); sendTemplatedEmailRequest.SetTemplate(templateName); std::ostringstream templateDataStream; templateDataStream << "{"; size_t dataCount = 0; for (auto &pair: templateData) { templateDataStream << "\"" << pair.first << "\":\"" << pair.second << "\""; dataCount++; if (dataCount < templateData.size()) { templateDataStream << ","; } } templateDataStream << "}"; sendTemplatedEmailRequest.SetTemplateData(templateDataStream.str()); if (!senderEmailAddress.empty()) { sendTemplatedEmailRequest.SetSource(senderEmailAddress); } if (!replyToAddress.empty()) { sendTemplatedEmailRequest.AddReplyToAddresses(replyToAddress); } auto outcome = sesClient.SendTemplatedEmail(sendTemplatedEmailRequest); if (outcome.IsSuccess()) { std::cout << "Successfully sent templated message with ID " << outcome.GetResult().GetMessageId() << "." << std::endl; } else { std::cerr << "Error sending templated message. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 SendTemplatedEmail AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 UpdateTemplate
。
- C++ 的 SDK
-
注意
還有更多 on 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 詳細資訊,請參閱 UpdateTemplate AWS SDK for C++ 參考中的 API。
-
下列程式碼範例示範如何使用 VerifyEmailIdentity
。
- C++ 的 SDK
-
注意
還有更多 on GitHub。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫
中設定和執行。 //! Add an email address to the list of identities associated with this account and //! initiate verification. /*! \param emailAddress; The email address to add. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::verifyEmailIdentity(const Aws::String &emailAddress, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::VerifyEmailIdentityRequest verifyEmailIdentityRequest; verifyEmailIdentityRequest.SetEmailAddress(emailAddress); Aws::SES::Model::VerifyEmailIdentityOutcome outcome = sesClient.VerifyEmailIdentity(verifyEmailIdentityRequest); if (outcome.IsSuccess()) { std::cout << "Email verification initiated." << std::endl; } else { std::cerr << "Error initiating email verification. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
如需 API 詳細資訊,請參閱 VerifyEmailIdentity AWS SDK for C++ 參考中的 API。
-
案例
下列程式碼範例示範如何建立 Web 應用程式,追蹤 Amazon Aurora Serverless 資料庫中的工作項目,並使用 Amazon Simple Email Service (Amazon SES) 傳送報告。
- C++ 的 SDK
-
說明如何建立可追蹤和報告存放在 Amazon Aurora Serverless 資料庫中的工作項目的 Web 應用程式。
如需有關如何設定查詢 Amazon Aurora Serverless 資料並供 React 應用程式使用之 C++ REST API 的完整原始程式碼和指示,請參閱 GitHub
上的完整範例。 此範例中使用的服務
Aurora
Amazon RDS
Amazon RDS Data Service
Amazon SES