.

Automated Birthday Email Script using Google Spreadsheets

We usually forget birthdays of our near and dear ones. Facebook help us a lot with the notifications but who is there to take care when you do not check your facebook account.

A good solutions is to set up an automated mailer for the wishes.

Steps:

1. You need to keep data in Google spreadsheets in this format. In Cell D6, type this formula

=AND(day(B6)=day(today()),month(today())=month(B6))

and drag it till end.
 

2. Go to Tools > Script Editor and paste this code there. Save the script.


function sendwishes() {
   var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[0]);
  var sheet = spreadsheet.getActiveSheet();
   
  var lastRow = sheet.getLastRow();
  var startRow = 6;
 
  var msg = "";
  
  for (var i =startRow ; i <= lastRow; i++) {
    if(sheet.getRange(i, 4).getValue()==true) {
       MailApp.sendEmail(sheet.getRange(i, 3).getValue(),
        "BirthDay Wishes", "Hi " + sheet.getRange(i, 1).getValue() + "\n\n" + sheet.getRange(2, 2).getValue() + "\n\n" + "Regards,\n" + "YOUR NAME\nYOUR COMPANY");  
    }
  } 
};


3. In Script editor, open Resources >  All your Triggers

4. Create a new trigger. 
     Run > <function name>
     Events > Time Driven + Day Timer

And That's all..!

2 comments :

  1. Hi, Thank you for your excellent script.
    May I know, how i could add HTML Template to make this email a bit nice

    ReplyDelete
  2. Thanks for your script. How can i attach an html page with this mail...

    ReplyDelete

Recent Posts