Back
Version 21
2/5/2024
import { email as sendEmail } from "https://esm.town/v/std/email?v=9";
let sendPDF = async (subject, body) => {
const { jsPDF } = await import("npm:jspdf");
const doc = new jsPDF();
doc.text(body, 10, 10);
return sendEmail({
text: "PDFified: " + subject,
attachments: [{
content: btoa(doc.output()),
filename: (subject || "Untitled") + ".pdf",
type: "application/pdf",
disposition: "attachment",
}],
});
};
export default async function(email: Email) {
console.log("received: " + email.subject);
sendPDF(email.subject, email.body);
}
Updated: February 5, 2024