Gunakan DeleteEmailIdentity dengan AWS SDK atau CLI - AWS SDKContoh Kode

Ada lebih banyak AWS SDK contoh yang tersedia di GitHub repo SDKContoh AWS Dokumen.

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan DeleteEmailIdentity dengan AWS SDK atau CLI

Contoh kode berikut menunjukkan cara menggunakanDeleteEmailIdentity.

Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:

.NET
AWS SDK for .NET
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

/// <summary> /// Deletes an email identity (email address or domain). /// </summary> /// <param name="emailIdentity">The email address or domain to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteEmailIdentityAsync(string emailIdentity) { var request = new DeleteEmailIdentityRequest { EmailIdentity = emailIdentity }; try { var response = await _sesClient.DeleteEmailIdentityAsync(request); return response.HttpStatusCode == HttpStatusCode.OK; } catch (ConcurrentModificationException ex) { Console.WriteLine($"The email identity {emailIdentity} is being modified by another operation or thread."); Console.WriteLine(ex.Message); } catch (NotFoundException ex) { Console.WriteLine($"The email identity {emailIdentity} 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 email identity: {ex.Message}"); } return false; }
Java
SDKuntuk Java 2.x
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

try { // Delete the email identity DeleteEmailIdentityRequest deleteIdentityRequest = DeleteEmailIdentityRequest.builder() .emailIdentity(this.verifiedEmail) .build(); sesClient.deleteEmailIdentity(deleteIdentityRequest); System.out.println("Email identity deleted: " + this.verifiedEmail); } catch (NotFoundException e) { // If the email identity does not exist, log the error and proceed System.out.println("Email identity not found. Skipping deletion..."); } catch (Exception e) { System.err.println("Error occurred while deleting the email identity: " + e.getMessage()); e.printStackTrace(); } } else { System.out.println("Skipping email identity deletion."); }
Python
SDKuntuk Python (Boto3)
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode 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_email_identity(EmailIdentity=self.verified_email) print(f"Email identity '{self.verified_email}' deleted successfully.") except ClientError as e: # If the email identity doesn't exist, skip and proceed if e.response["Error"]["Code"] == "NotFoundException": print(f"Email identity '{self.verified_email}' does not exist.") else: print(e)
Rust
SDKuntuk Rust
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara pengaturan dan menjalankannya di Repositori Contoh Kode AWS.

match self .client .delete_email_identity() .email_identity(self.verified_email.clone()) .send() .await { Ok(_) => writeln!(self.stdout, "Email identity deleted successfully.")?, Err(e) => { return Err(anyhow!("Error deleting email identity: {}", e)); } }