I try to send email via AWS SDK
I have accessKey and secretKey.
var accessKey = "";
var secretKey = "";
var region = RegionEndpoint.USEast1; // Use the appropriate region
var credentials = new Amazon.Runtime.BasicAWSCredentials(accessKey, secretKey);
var config = new AmazonSimpleEmailServiceConfig { RegionEndpoint = RegionEndpoint.USEast1 };
using var client = new AmazonSimpleEmailServiceClient(credentials, config);
var sendRequest = new SendEmailRequest
{
Source = "[email protected]",
Destination = new Destination
{
ToAddresses =
new List<string> { "[email protected]" }
},
Message = new Message
{
Subject = new Content("Test email"),
Body = new Body
{
Html = new Content
{
Charset = "UTF-8",
Data = "<h1>Hello</h1><p>This is a test email sent using Amazon SES.</p>"
},
Text = new Content
{
Charset = "UTF-8",
Data = "Hello, this is a test email sent using Amazon SES."
}
}
}
};
try
{
var response = await client.SendEmailAsync(sendRequest);
Console.WriteLine("Email sent! Message ID: " + response.MessageId);
}
catch (Exception ex)
{
Console.WriteLine("Error sending email: " + ex.Message);
}
But I got error message:
The security token included in the request is invalid.
Is it possible send email If I have only AccessKey and SecretKey ?
Or I have to generate token ?