-
Notifications
You must be signed in to change notification settings - Fork 0
/
reportData
63 lines (57 loc) · 1.78 KB
/
reportData
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
"week": "Week 1",
"project": "Product Management System",
"status": "On Track",
"highlights": [
"Completed user authentication module",
"Integrated payment gateway",
"Fixed bugs in the reporting module"
],
"nextSteps": [
"Start development of the dashboard",
"Conduct user testing",
"Prepare for the next sprint planning"
],
"issues": [
"Delay in API integration",
"Need more resources for frontend development"
]
}
const fs = require('fs');
const nodemailer = require('nodemailer');
// Read report data from JSON file
const reportData = JSON.parse(fs.readFileSync('reportData.json', 'utf8'));
// Generate HTML report
const generateReport = (data) => {
return `
<h2>${data.project} - ${data.week}</h2>
<p><strong>Status:</strong> ${data.status}</p>
<h3>Highlights</h3>
<ul>${data.highlights.map(item => `<li>${item}</li>`).join('')}</ul>
<h3>Next Steps</h3>
<ul>${data.nextSteps.map(item => `<li>${item}</li>`).join('')}</ul>
<h3>Issues</h3>
<ul>${data.issues.map(item => `<li>${item}</li>`).join('')}</ul>
`;
};
// Save the report as an HTML file
fs.writeFileSync('weeklyReport.html', generateReport(reportData));
// Send the report via email
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'wStxv3st'
}
});
const mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Weekly Report',
html: generateReport(reportData)
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Report sent: ' + info.response);
});