Online Automated Follow-Up Email Generator Automated Follow-Up Email Generator Craft the perfect follow-up email in seconds. 1. Email Generator 2. Template Configuration Email Details Recipient's Name Your Name Context Goal Thank you for your time Inquire about next steps Provide requested documents Nudge for a response Tone Formal Semi-Formal Casual Generate Emails Generated Emails Your generated emails will appear here. Download Emails as PDF Manage Email Snippets Customize the building blocks of your emails. Use placeholders like [Recipient], [Sender], [Context], and [Goal] where appropriate. Opening Lines Gratitude Phrases Calls to Action Closing Lines ${email.body} `).join(''); downloadPdfBtn.disabled = false; } // --- EVENT HANDLERS & HELPERS --- function getRandom(arr) { return arr[Math.floor(Math.random() * arr.length)]; } function handleAddSnippet(e) { if (e.key === 'Enter' && e.target.classList.contains('snippet-input')) { const type = e.target.dataset.type; const value = e.target.value.trim(); if (value) { // Add to all tones/goals for simplicity in this tool Object.keys(snippets[type]).forEach(key => { snippets[type][key].push(value); }); e.target.value = ''; renderAllConfig(); } } } function handleDeleteSnippet(e) { if (e.target.tagName === 'BUTTON' && e.target.dataset.type) { const { type, key, phrase } = e.target.dataset; // For simplicity, remove from all matching keys (tones/goals) Object.keys(snippets[type]).forEach(k => { snippets[type][k] = snippets[type][k].filter(p => p !== phrase); }); renderAllConfig(); } } function handleCopy(e) { if (e.target.classList.contains('copy-btn')) { const card = e.target.closest('.email-card'); const content = card.querySelector('.email-content').innerText; const el = document.createElement('textarea'); el.value = content; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); e.target.textContent = 'Copied!'; setTimeout(() => { e.target.textContent = 'Copy'; }, 2000); } } function generatePdf() { const { jsPDF } = window.jspdf; const pdfContent = document.getElementById('pdf-content'); const pdfTitleEl = document.getElementById('pdf-title'); if (!pdfContent || downloadPdfBtn.disabled) return; pdfTitleEl.textContent = 'Generated Follow-Up Emails'; html2canvas(pdfContent, { scale: 2, useCORS: true, logging: false }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const ratio = canvas.width / canvas.height; const imgHeight = (pdfWidth - 20) / ratio; pdf.addImage(imgData, 'PNG', 10, 10, pdfWidth - 20, imgHeight); pdf.save('Follow-Up-Emails.pdf'); pdfTitleEl.textContent = ''; }); } // --- EVENT LISTENERS --- function addEventListeners() { tabButtons.forEach(button => { button.addEventListener('click', () => { const tab = button.dataset.tab; tabButtons.forEach(btn => btn.classList.toggle('active', btn.dataset.tab === tab)); tabContents.forEach(content => content.classList.toggle('active', content.id.startsWith(tab))); }); }); generateBtn.addEventListener('click', generateEmails); configContainer.addEventListener('keypress', handleAddSnippet); configContainer.addEventListener('click', handleDeleteSnippet); resultsContainer.addEventListener('click', handleCopy); downloadPdfBtn.addEventListener('click', generatePdf); } initialize(); });