0

Send mail merge

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Send mail merge
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  id: string,
12
  _module: string,
13
  body: {
14
    send_mail_merge?: {
15
      mail_merge_template?: { id?: string; name?: string };
16
      from_address?: { type?: string; value?: string };
17
      to_address?: { type?: string; value?: string }[];
18
      cc_email?: { type?: string; value?: string }[];
19
      bcc_email?: { type?: string; value?: string }[];
20
      subject?: string;
21
      message?: string;
22
      type?: string;
23
      attachment_name?: string;
24
    }[];
25
  },
26
) {
27
  const url = new URL(
28
    `https://zohoapis.com/crm/v8/${_module}/${id}/actions/send_mail_merge`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "POST",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: "Zoho-oauthtoken " + auth.token,
36
    },
37
    body: JSON.stringify(body),
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45