//native
type Zoho = {
token: string;
};
/**
* Send mail merge
*
*/
export async function main(
auth: Zoho,
id: string,
_module: string,
body: {
send_mail_merge?: {
mail_merge_template?: { id?: string; name?: string };
from_address?: { type?: string; value?: string };
to_address?: { type?: string; value?: string }[];
cc_email?: { type?: string; value?: string }[];
bcc_email?: { type?: string; value?: string }[];
subject?: string;
message?: string;
type?: string;
attachment_name?: string;
}[];
},
) {
const url = new URL(
`https://zohoapis.com/crm/v8/${_module}/${id}/actions/send_mail_merge`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago