-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendTransactionalEmails.ts
49 lines (41 loc) · 1.33 KB
/
sendTransactionalEmails.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* Initialization */
import { Configuration, EmailsApi, EmailTransactionalMessageData } from '@elasticemail/elasticemail-client-ts-axios';
/* Generate and use your API key */
const config = new Configuration({
apiKey: "YOUR_API_KEY"
});
/**
* Send transactional emails
* Example of sending transactional emails
*/
const emailsApi = new EmailsApi(config);
const emailTransactionalMessageData = {
Recipients: {
To: ["example@address.com"] // maximum 50 recipients
},
Content: {
Body: [
{
ContentType: "HTML",
Charset: "utf-8",
Content: "<strong>Example content<strong>"
},
{
ContentType: "PlainText",
Charset: "utf-8",
Content: "Example content"
}
],
From: "myemail@address.com",
Subject: "Example transactional email"
}
}; // interface EmailTransactionalMessageData from '@elasticemail/elasticemail-client-ts-axios'
const sendTransactionalEmails = (emailTransactionalMessageData: EmailTransactionalMessageData): void => {
emailsApi.emailsTransactionalPost(emailTransactionalMessageData).then((response) => {
console.log('API called successfully.');
console.log(response.data);
}).catch((error) => {
console.error(error);
});
};
sendTransactionalEmails(emailTransactionalMessageData);