Skip to content

Unable to retrieve emails from the SES archive via NODE.js GetArchiveMessageCommand

0

Hello everyone! currently im working with ses and i want to extract the emails ive sent that are stored in the SES archive. I've found this API reference for it in this link where it explains how to retrieve an archive email with its corresponding "ArchivedMessageId" descived as "The unique identifier of the archived email message.". Then following the guide for the implementation on java script i've arrived to this point:

const { MailManagerClient, GetArchiveMessageCommand } = require("@aws-sdk/client-mailmanager");
const config = credentials: {
                accessKeyId: "KEYKEYKEYCIAO",
                secretAccessKey: "KEYKEYKEYCIAO/KEYKEYKEYCIAO"

            }, region: "eu-central-1"
        }
        const client = new MailManagerClient(config);
        const input = { // GetArchiveMessageRequest
            ArchivedMessageId: "01070197a7559e1b-f3ddf1ff-ce69-4e67-8506-462b81143692-000000", // required
        };
        const command = new GetArchiveMessageCommand(input);
        const response = await client.send(command);

the error im getting is

ValidationException: Invalid ArchivedMessageId
 at de_ValidationExceptionRes (/app/node_modules/@aws-sdk/client-mailmanager/dist-cjs/protocols/Aws_json1_0.js:1354:23)
 at de_CommandError (/app/node_modules/@aws-sdk/client-mailmanager/dist-cjs/protocols/Aws_json1_0.js:1290:25)
 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 at async /app/node_modules/@smithy/middleware-serde/dist-cjs/index.js:36:20
 at async /app/node_modules/@smithy/core/dist-cjs/index.js:193:18
 at async /app/node_modules/@smithy/middleware-retry/dist-cjs/index.js:320:38
 at async /app/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:33:22
 at async getEmailAws (/app/controllers/renewal-dashboard-actions.js:444:26) {
 '$fault': 'client',
 '$metadata': {
 httpStatusCode: 400,
 requestId: 'ced21435-2ca6-4ca6-8df2-dc1a3126c559',
 extendedRequestId: undefined,
  cfId: undefined,
 attempts: 1,
 totalRetryDelay: 0
  },
 __type: 'com.amazon.pancetta#ValidationException'
}

I don't understand what im doing wrong. ive tried different combinations for the "ArchivedMessageId" as on the archive of SES Enter image description here i see : <01070197a7559e1b-f3ddf1ff-ce69-4e67-8506-462b81143692-000000@eu-central-1.amazonses.com> as the message id but with no luck. Also tried to remove the "<>" and different parts of the ID with no avail. I just want confirmation that the email id is correct and the problem is elsewhere because im stunned and havent found any other information elsewhere

Thanks!

2 Answers
6

The ArchivedMessageId must match exactly the identifier provided by the SES Mail Manager archive search. It is distinct from the Message-ID found in the email headers (e.g., 01070197a7559e1b-f3ddf1ff-ce69-4e67-8506-462b81143692-000000@eu-central-1.amazonses.com) and should not be used interchangeably.

Please try:

  1. Go to SES > Mail Manager > Email Archiving > Search archive.
  2. Search for the email.
  3. In the results, look for the Archived Message ID field (not the Message-ID).
  4. Use that exact value in your GetArchiveMessageCommand.
EXPERT

answered a year ago

  • Hey there Kidd Ip! Thanks for answering first of all, but i don't seem to find the value you are mentioning in the visible columns of the search result. I saw on the properties to see the columns and see there are only "Received date" , "Subject line", "From", "To", "Envelope From", "Envelope To", "Cc", "Message Id". I dont seem to find this value. Do you see it on your archive? If you have an example could you share it with me? i assume is something like "messageID + ArchiveID" but if not i have no clue. Thanks again! have a good one

0

Hey,

Hope you're keeping well.

The Invalid ArchivedMessageId error means SES Mail Manager can’t find a message with that ID in the archive you’re querying. The ArchivedMessageId must come from a prior ListArchiveMessages API call for the same archive in the same region. Make sure you’re using the correct archive name in your list call, and that the message hasn’t expired or been deleted based on your retention policy. Also verify your IAM role has ses:GetArchiveMessage permission for that archive resource. If you hardcoded the ID from elsewhere, retrieve it dynamically via ListArchiveMessages before calling GetArchiveMessage.

Thanks and regards,
Taz

answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.