-
Notifications
You must be signed in to change notification settings - Fork 5
/
emailHelper.js
124 lines (102 loc) · 4.31 KB
/
emailHelper.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
* See LICENSE in the project root for license information.
*/
// The contents of the outbound email message that will be sent to the user
var emailContent = (function () {/*
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content=
"HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
<meta http-equiv='Content-Type' content='text/html; charset=us-ascii' />
<title></title>
</head>
<body style='font-family:calibri'>
<h2>Congratulations!</h2>
<p>This is a message from the <a href='https://github.com/PaulStubbs/nodejs-alexa-connect-sample'>Microsoft Graph Alexa Connect Skill Sample</a>.
You are well on your way to incorporating Microsoft Graph endpoints in your apps.</p>
<h3>What's next?</h3>
<ul>
<li>Check out <a href='https://graph.microsoft.io'>graph.microsoft.io</a> to start
building Microsoft Graph apps today with all the latest tools, templates, and
guidance to get started quickly.</li>
<li>Use the <a href='https://graph.microsoft.io/graph-explorer'>Graph explorer</a> to
explore the rest of the APIs and start your testing.</li>
<li>Browse other <a href='https://github.com/microsoftgraph/'>samples on GitHub</a>
to see more of the APIs in action.</li>
<li>Use the <a href='http://graph.microsoft.io/code-samples-and-sdks'>Microsoft Graph
SDK Client Libraries</a> to integrate additional Microsoft services and data into
your own apps.</li>
</ul>
<h3>Give us feedback</h3>
<p>If you have any trouble running this sample, please <a href=
'https://github.com/PaulStubbs/nodejs-alexa-connect-sample/issues'>log an issue</a> on
our repository.</p>
<p>For general questions about the Microsoft Graph API, post to <a href=
'https://stackoverflow.com/questions/tagged/microsoftgraph'>Stack Overflow</a>. Make
sure that your questions or comments are tagged with [microsoftgraph].</p>
<p>Thanks, and happy coding!<br />
Your Microsoft Graph samples development team</p>
<div style='text-align:center; font-family:calibri'>
<table style='width:100%; font-family:calibri'>
<tbody>
<tr>
<td><a href=
'https://github.com/PaulStubbs/nodejs-alexa-connect-sample'>See on
GitHub</a></td>
<td><a href='https://office365.uservoice.com'>Suggest on UserVoice</a></td>
<td><a href=
'https://twitter.com/share?text=I%20just%20started%20developing%20skills%20for%20%23AmazonAlexa%20using%20the%20%23MicrosoftGraph%20Connect%20sample%20%40OfficeDev%20%40AlexaDev&url=https://github.com/PaulStubbs/nodejs-alexa-connect-sample'>
Share on Twitter</a></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
*/}).toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1];
/**
* Returns the outbound email message content with the supplied name populated in the text
* @param {string} name The proper noun to use when addressing the email
* @return {string} the formatted email body
*/
function getEmailContent(name) {
return emailContent.replace('{{name}}', name);
}
/**
* Wraps the email's message content in the expected [soon-to-deserialized JSON] format
* @param {string} content the message body of the email message
* @param {string} recipient the email address to whom this message will be sent
* @return the message object to send over the wire
*/
function wrapEmail(content, recipient) {
var emailAsPayload = {
Message: {
Subject: 'Welcome to the Microsoft Graph Alexa Connect Skill Sample',
Body: {
ContentType: 'HTML',
Content: content
},
ToRecipients: [
{
EmailAddress: {
Address: recipient
}
}
]
},
SaveToSentItems: true
};
return emailAsPayload;
}
/**
* Delegating method to wrap the formatted email message into a POST-able object
* @param {string} name the name used to address the recipient
* @param {string} recipient the email address to which the connect email will be sent
*/
function generateMailBody(name, recipient) {
return wrapEmail(getEmailContent(name), recipient);
}
exports.generateMailBody = generateMailBody;