-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbasicSendWithAmpBodyExample.js
More file actions
48 lines (43 loc) · 1.31 KB
/
basicSendWithAmpBodyExample.js
File metadata and controls
48 lines (43 loc) · 1.31 KB
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
const { SocketLabsClient, EmailAddress, BasicMessage } = require('../../src/socketlabsClient');
const exampleConfig = require('../exampleConfig');
/**
* Build the message
*/
var message = new BasicMessage();
message.subject = "Sending A Test Message (Basic Send with Amp)";
message.htmlBody = "<html><body><h1>Sending A Test Message</h1><p>This HTML will show if AMP is not supported.</p></body></html>";
message.ampBody = "<!doctype html>" +
"<html amp4email>" +
"<head>" +
" <meta charset=\"utf-8\">" +
" <script async src=\"https://cdn.ampproject.org/v0.js\"></script>" +
" <style amp4email-boilerplate>body{visibility:hidden}</style>" +
" <style amp-custom>" +
" h1 {" +
" margin: 1rem;" +
" }" +
" </style>" +
"</head>" +
"<body>" +
" <h1>This is the AMP Html Body of my message</h1>" +
"</body>" +
"</html>";
message.from = new EmailAddress("from@example.com");
message.to.push("recipient@example.com");
/**
* Create the client
*/
var client = new SocketLabsClient(exampleConfig.ServerId, exampleConfig.ApiKey);
/**
* Send the message
*/
client.send(message).then(
(res) => {
console.log("Promise resolved: ")
console.log(res)
},
(err) => {
console.log("Promise rejected: ")
console.log(err)
}
);