Last active
February 4, 2025 17:39
-
-
Save souhailmerroun/2a41186534d283a1df6ce5d2262e530c to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendFIREEmail() { | |
// 1. Define your monthly expenses (hardcoded example): | |
var monthlyExpenses = 2162.71; // Replace with your actual monthly expense | |
// 2. Calculate annual expenses | |
var annualExpenses = monthlyExpenses * 12; | |
// 3. FIRE target using the 4% rule (annualExpenses / 0.04) | |
var fireTarget = annualExpenses / 0.04; | |
// 4. Format numbers for readability | |
var monthlyFormatted = monthlyExpenses.toLocaleString( | |
"en-GB", { minimumFractionDigits: 2, maximumFractionDigits: 2 } | |
); | |
var annualFormatted = annualExpenses.toLocaleString( | |
"en-GB", { minimumFractionDigits: 2, maximumFractionDigits: 2 } | |
); | |
var fireTargetFormatted = Math.round(fireTarget).toLocaleString("en-GB"); | |
// 5. Get the current logged-in user's email | |
var userEmail = Session.getActiveUser().getEmail(); | |
// 6. Compose the email message, explaining what this FIRE target "replaces" | |
var message = | |
"Hello!\n\n" + | |
"Your monthly expenses are estimated at €" + monthlyFormatted + ".\n" + | |
"That means your annual expenses are approximately €" + annualFormatted + ".\n\n" + | |
"Based on the 4% rule, you need around €" + fireTargetFormatted + | |
" invested to sustainably withdraw 4% (i.e., ~€" + annualFormatted + | |
" each year) and replace these expenses.\n\n" + | |
"In other words, having ~€" + fireTargetFormatted + " invested could " + | |
"cover your monthly costs of €" + monthlyFormatted + " indefinitely.\n\n" + | |
"All the best on your journey to Financial Independence!\n"; | |
// 7. Send the email | |
MailApp.sendEmail({ | |
to: userEmail, | |
subject: "Your FIRE Target – Replacing Monthly Expenses", | |
body: message | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment