DeleteContactList搭配使用 AWS SDK - Amazon Simple Email Service

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

DeleteContactList搭配使用 AWS SDK

以下代码示例演示如何使用 DeleteContactList

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

.NET
AWS SDK for .NET
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

/// <summary> /// Deletes a contact list and all contacts within it. /// </summary> /// <param name="contactListName">The name of the contact list to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteContactListAsync(string contactListName) { var request = new DeleteContactListRequest { ContactListName = contactListName }; try { var response = await _sesClient.DeleteContactListAsync(request); return response.HttpStatusCode == HttpStatusCode.OK; } catch (ConcurrentModificationException ex) { Console.WriteLine($"The contact list {contactListName} is being modified by another operation or thread."); Console.WriteLine(ex.Message); } catch (NotFoundException ex) { Console.WriteLine($"The contact list {contactListName} does not exist."); Console.WriteLine(ex.Message); } catch (TooManyRequestsException ex) { Console.WriteLine("Too many requests were made. Please try again later."); Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine($"An error occurred while deleting the contact list: {ex.Message}"); } return false; }
  • 有关API详细信息,请参阅 “AWS SDK for .NET API参考 DeleteContactList” 中的。

Java
SDK适用于 Java 2.x
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

try { // Delete the contact list DeleteContactListRequest deleteContactListRequest = DeleteContactListRequest.builder() .contactListName(CONTACT_LIST_NAME) .build(); sesClient.deleteContactList(deleteContactListRequest); System.out.println("Contact list deleted: " + CONTACT_LIST_NAME); } catch (NotFoundException e) { // If the contact list does not exist, log the error and proceed System.out.println("Contact list not found. Skipping deletion..."); } catch (Exception e) { System.err.println("Error occurred while deleting the contact list: " + e.getMessage()); e.printStackTrace(); }
  • 有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 DeleteContactList” 中的。

Python
SDK适用于 Python (Boto3)
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

def main(): """ The main function that orchestrates the execution of the workflow. """ print(INTRO) ses_client = boto3.client("sesv2") workflow = SESv2Workflow(ses_client) try: workflow.prepare_application() workflow.gather_subscriber_email_addresses() workflow.send_coupon_newsletter() workflow.monitor_and_review() except ClientError as e: print_error(e) workflow.clean_up() class SESv2Workflow: """ A class to manage the SES v2 Coupon Newsletter Workflow. """ def __init__(self, ses_client, sleep=True): self.ses_client = ses_client self.sleep = sleep try: self.ses_client.delete_contact_list(ContactListName=CONTACT_LIST_NAME) print(f"Contact list '{CONTACT_LIST_NAME}' deleted successfully.") except ClientError as e: # If the contact list doesn't exist, skip and proceed if e.response["Error"]["Code"] == "NotFoundException": print(f"Contact list '{CONTACT_LIST_NAME}' does not exist.") else: print(e)
  • 有关API详细信息,请参阅DeleteContactList中的 AWS SDKPython (Boto3) API 参考。

Rust
SDK对于 Rust
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

match self .client .delete_contact_list() .contact_list_name(CONTACT_LIST_NAME) .send() .await { Ok(_) => writeln!(self.stdout, "Contact list deleted successfully.")?, Err(e) => return Err(anyhow!("Error deleting contact list: {e}")), }
  • 有关API详细信息,请参见DeleteContactList中的 Rust AWS SDK API 参考

有关 AWS SDK开发者指南和代码示例的完整列表,请参阅将 Amazon SES 与 AWS SDK。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。