Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for IEDC recruitment #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 68 additions & 68 deletions functions/mail.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
const fs = require("fs");
const csv = require("csv-parser");
const qrcode = require("qrcode");
const nodemailer = require("nodemailer");
const Jimp = require("jimp");
const fs = require("fs")
const csv = require("csv-parser")
const qrcode = require("qrcode")
const nodemailer = require("nodemailer")
const Jimp = require("jimp")

const csvFilePath = "./demo.csv";
const outputDir = "./qrcodes";
const csvFilePath = "./bruh.csv"
//const outputDir = "./qrcodes";

if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
// if (!fs.existsSync(outputDir)) {
// fs.mkdirSync(outputDir);
// }

const transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
port: 587,
pool: true,
auth: {
user: "[email protected]",
pass: "pass",
user: "addyouremailhere",
pass: "addyourpasswordhere",
},
});
})

let counter = 0;
let counter = 0
const emailText = (name) => `Dear ${name},

We hope you are excited about Technohack!
As we approach the hackathon, we want to ensure that the registration process is smooth and easy for everyone.
Please take note of the following instructions regarding registration:

- You will receive a unique QR code as an attachment to this email.
- Please report to the registration desk with your QR code.
- Show your QR code at the counter.
- Our volunteers will scan your QR code and you will receive a name tag with a new QR code pasted on it.
- Please stick or keep your name tag safely throughout the hackathon duration.
- For dinner, snacks, breakfast, and lunch, please show your QR code at the counters.
- If you have any doubts or questions, our voluntees will be happy to assist you.

We hope this information makes the registration process easier for you.
If you have any further questions or concerns, please feel free to reach out to us.

Best regards,

The Technohack Team`;
<br></br>
<br></br>
We are thrilled to extend our heartfelt congratulations to you on your well-deserved selection to our esteemed club! Your hard work, dedication, and passion have truly paid off, and it is an absolute pleasure to welcome you as a valued member of our vibrant community.
<br></br>
<br></br>
Click on the following link to join the IEDC MEC Tech Team WhatsApp Group. This group will be used to communicate with you regarding all the activities of the club.
<br></br>
<br></br>
<div style="font-size: 10px">
<a href="https://chat.whatsapp.com/JyeXKtK8Gix35fN1IDlfBA" style="background-color: #4CAF50; color: #fff; padding: 5px 10px; text-decoration: none; border-radius: 2px; display: inline-block;">Join Group</a>
</div>
<br></br>
If you have any questions or need assistance with anything, please do not hesitate to reach out to us. We are here to support you and ensure that your journey with us is memorable and impactful.
<br></br>
<br></br>
Warm regards,
<br></br>
<br></br>
<strong>Jaison Dennis</strong><br></br>
<strong>CTO | IEDC MEC</strong><br></br>`

const main = () => {
fs.createReadStream(csvFilePath)
.pipe(csv())
.on("data", async (row) => {
const id = row.id;
const email = row.email;
const name = row.name;
const qrCodeData = id;
const qrCodePath = `${outputDir}/${id}.png`;
// const id = row.id;
const email = row["Email ID"]
const name = row["Name"]
// const qrCodeData = id;
// const qrCodePath = `${outputDir}/${id}.png`;
try {
await qrcode.toFile(qrCodePath, qrCodeData, {
color: {
dark: "#000000",
light: "#FFFFFF",
},
scale: 11,
margin: 2,
});
// await qrcode.toFile(qrCodePath, qrCodeData, {
// color: {
// dark: "#000000",
// light: "#FFFFFF",
// },
// scale: 11,
// margin: 2,
// });

const qrImage = await Jimp.read(qrCodePath);
const font = await Jimp.loadFont(Jimp.FONT_SANS_16_BLACK);
qrImage.print(font, 130, qrImage.bitmap.height - 20, id);
await qrImage.writeAsync(qrCodePath);
// const qrImage = await Jimp.read(qrCodePath);
// const font = await Jimp.loadFont(Jimp.FONT_SANS_16_BLACK);
// qrImage.print(font, 130, qrImage.bitmap.height - 20, id);
// await qrImage.writeAsync(qrCodePath);
const mailOptions = {
from: "[email protected]",
to: email,
subject: "Technohack 2023 - Registration Details",
text: emailText(name),
attachments: [
{
filename: `${id}.png`,
path: qrCodePath,
},
],
};
subject: "Congratulations on Your Selection to IEDC MEC Tech Team",
html: emailText(name),
// attachments: [
// {
// filename: `${id}.png`,
// path: qrCodePath,
// },
// ],
}

// if (counter++ % 1 === 0) {
// console.log("Pausing for 15 seconds...");
// await new Promise((resolve) => setTimeout(resolve, 15000));
// console.log("Resuming...");
// }
await transporter.sendMail(mailOptions);
console.log(`Sent QR code for id ${id} to ${email}`);
await transporter.sendMail(mailOptions)

console.log(`Sent QR code for id to ${email}`)
} catch (error) {
console.error(
`Failed to send QR code for id ${id} to ${email}: ${error}`
);
console.error(`Failed to send QR code for id to ${email}: ${error}`)
}
})
.on("end", () => {
console.log("Done generating and sending QR codes");
});
};
console.log("Done generating and sending QR codes")
})
}

main();
main()