--- title: "Code the Job Function" url: https://docs.catalyst.zoho.com/en/tutorials/birthday-greetings/nodejs/code-job-func/ description: "Build a birthday greetings application using the Job Scheduling service and automatically send out birthday greetings to the required person via their email." last_updated: 2025-11-19T15:07:41Z service: All Services type: tutorial related_links: - name: "Job Functions" url: /en/serverless/help/functions/job-functions/ - name: "Job Scheduling SDK" url: /en/sdk/nodejs/v2/job-scheduling/overview/ - name: "Job Scheduling API" url: /en/api/code-reference/job-scheduling/jobpool/get-all-jobpool/#GetAllJobPools --- # Code the Job Function Now let's code the job function that will be triggered when a Function Job is executed from the Function Job Pool. This function will be used to send out the birthday greeting to the required person via their email. This function will be employing the [Mail SDK](https://docs.catalyst.zoho.com/en/sdk/nodejs/v2/cloud-scale/mail/send-email/). The job function present in the [functions](https://docs.catalyst.zoho.com/en/cli/v1/project-directory-structure/functions-directory/) directory, `BirthdayGreetings/functions/dynamic_cron/` contains: * The `index.js` main function file * The `catalyst-config.json` configuration file * Node modules * [`package.json`](https://docs.npmjs.com/files/package.json) and [`package-lock.json`](https://docs.npmjs.com/configuring-npm/package-lock-json.html) dependency files. You will be adding code in the `index.js` file. Copy the code given below and paste it in the `index.js` file. > **Note:** Please go through the code in this section to make sure you fully understand it. **index.js** ```javascript 'use strict'; const catalyst = require('zcatalyst-sdk-node'); module.exports = async (jobRequest, context) => { const catalystApp = catalyst.initialize(context); try { console.log("Jobs", jobRequest.getAllJobParams()); const { id, name, email, message, birthday } = jobRequest.getAllJobParams(); await catalystApp.email().sendMail({ from_email: 'emmy@zylker.com', // Add sender's email address to_email: [email], html_mode: true, subject: `Birthday Wishes for ${name}`, content: `Hello ${name}, ${message}`, }); console.log(`Email sent successfully to ${email}`); context.closeWithSuccess('Email sent successfully.'); } catch (error) { console.error('Error:', error); context.closeWithFailure('Failed to send email.'); } }; ``` > **Note:** Ensure that you add the sender email address you configured using the Mail component in line `15`. All of the required functions have now been configured for your application.