I followed the instructions found here:
I am able to send emails, but CC and BCC aren't present.
I believe my issue is in this configuration right here (copied from the link above):
const params = {
ApplicationId: projectId,
MessageRequest: {
Addresses: {
Destination: {
ToAddresses: toAddress,
CcAddresses: ccAddresses,
BccAddresses: bccAddresses,
},
[toAddress]: {
ChannelType: "EMAIL",
},
},
MessageConfiguration: {
EmailMessage: {
FromAddress: senderAddress,
SimpleEmail: {
Subject: {
Charset: charset,
Data: subject,
},
HtmlPart: {
Charset: charset,
Data: body_html,
},
TextPart: {
Charset: charset,
Data: body_text,
},
},
},
},
},
};
This is the version that I have:
"@aws-sdk/client-pinpoint": "^3.183.0",
Any one got ideas on what I could be missing?
Ok, here is what I did to solve this. I couldn't find any example with 'client-pinpoint-EMAIL' so here is my own.
Min code example below:
const { PinpointEmail } = require("@aws-sdk/client-pinpoint-email");
const { SendEmailCommand } = require("@aws-sdk/client-pinpoint-email");
const pinClient = new PinpointEmail({
region: aws_region,
credentials: credentials,
});
const senderAddress = "NameOfYourFirm <hello@yourcompany.com>"
const toAddress = 'email_to_send_address@gmail.com'
const ccEmails = ['email_to_cc@gmail.com']
const params = {
FeedbackForwardingEmailAddress: senderAddress,
FromEmailAddress: senderAddress,
ReplyToAddresses: [senderAddress],
Destination: {
ToAddresses: [toAddress],
CcAddresses: ccEmails,
},
Content: {
Simple: {
Subject: {
Charset: charset,
Data: subject,
},
Body: {
Html: {
Charset: charset,
Data: body_html,
},
},
},
},
};
try {
const data = await pinClient.send(new SendEmailCommand(params));
console.log("Email sent! Message ID: ", data["MessageId"]);
return data;
} catch (err) {
console.log("Error", err);
}