Hi, I was trying to create an email notification function, the code below works perfectly for single recipient, but I can't added more recipients using cc/bcc.
I have tried so many syntax but can't find the correct one, anyone know how to solve this so I can add more emails using CC? I have tried both email and UID btw
recipientEmail: string,
subject: string,
content: string,
appointmentSchedule: Date
) => {
try {
const scheduledTime = new Date(appointmentSchedule).toISOString();
console.log(ID.unique());
// console.log(ccEmails);
console.log(recipientEmail);
const message = await messaging.createEmail(
ID.unique(), // Unique message ID
subject, // Subject of the email
content, // Content of the email
[], // Topics (optional)
[recipientEmail], // List of user emails (you can include more)
[], // Targets (optional)
["example@mail.com"], // CC (optional)
[], // BCC (optional)
[], // Attachments (optional)
false, // Draft (optional)
true, // HTML content
scheduledTime
);
return parseStringify(message);
} catch (error) {
console.error("An error occurred while sending email:", error);
}
};```
Here are the errors I encounter:
type: 'general_argument_invalid',
response: {
message: "Invalid `bcc` param: Value must a valid array and UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore",
code: 400,
type: 'general_argument_invalid',
version: '1.6.0'
}```
```code: 400,
type: 'message_target_not_email',
response: {
message: 'Message with the target ID is not an email target.',
code: 400,
type: 'message_target_not_email',
version: '1.6.0'
}```
You are supposed to use the target ID
Oh, may I know where I can get the ID sir?
Is it these IDs?
hmm it's not working
Recommended threads
- How Can I Create landing page in appwrit...
I created function called invoice URL https://app.getrestt.com/v1/functions/invoice/executions?id=test-76f948fe83c43422561fe096c0674a1bd3ff0702cdfcf2444293ab31...
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...