Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29927

Failed to retrieve credentials from EC2 Instance Metadata Service

$
0
0

I'm trying to send an email via the AWS SES API using the SDK.

I based my code off the official documentation here: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/examples-send-using-sdk.html

I'm getting as far as await client.SendEmailAsync(sendRequest); and receive the error message:

Failed to retrieve credentials from EC2 Instance Metadata Service.

// initialization
var client = new AmazonSimpleEmailServiceClient(RegionEndpoint.USWest2);
var response = new SendEmailResponse();

// build email
var sendRequest = new SendEmailRequest
{
    Source = ToAddress,
    Destination = new Destination
    {
        ToAddresses =
        new List<string> { ReceiverAddress }
    },
    Message = new Message
    {
        Subject = new Content(model.Subject),
        Body = new Body
        {
            Html = new Content
            {
                Charset = "UTF-8",
                Data = model.HtmlBody
            },
        }
    },
};

// send async call to api
try
{
    var response = await client.SendEmailAsync(sendRequest);
}
catch (Exception ex)
{

}

I've confirmed that my domain is verified via the AWS console and it's also showing as "Enabled for Sending".

Where am I going wrong?


Viewing all articles
Browse latest Browse all 29927

Trending Articles