1

I am trying to implement an automated solution to my company's birthday and anniversary emails. I already have a solution to send a personalised email to those employees on their birthdays. What I need is that those personalised emails have to be sent to everyone in my organisation. For example, there are 100 employees and 3 of them have their birthday today. All 100 employees should get 3 personalised emails (personalisation applied only for those who have their birthday today). I cannot figure out the logic to implement this in Marketing Cloud.

EDIT : I have already setup a filtered data extension which will retrieve all the employees whose birthday is today (runs daily; data is overwritten). I need some way to personalise the email with only the data present in this data extension. These personalised emails will go out to all the employees.

let me know if you need anything else.

Any help is appreciated. Thank you.

4

You could just send an email to your Employee Data Extension. In the email scripting, you could retrieve the rows from that same DE, iterate through all of the employees and calculate who's birthday is today. You'll need a static value for lookup on your Employees data extension:

%%[

var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i, @birthdayCount, @birthday, @firstName

set @numRowsToReturn = 0 
set @rows = LookupOrderedRows("Employees",@numRowsToReturn,"FirstName asc, LastName asc","lookupKey", "1")
set @rowCount = rowcount(@rows)

set @birthday = AttributeValue("birthdate")
set @firstName = AttributeValue("firstName")
set @today = now(1)
set @todayMonth = datePart(@today, "M")
set @todayDay = datePart(@today, "D")
set @birthMonth = datePart(@birthDate, "M")
set @birthDay = datePart(@birthDate, "D")    

if @todayMonth == @birthMonth and @todayDay == @birthDay then

    output(concat("<h1>Happy Birthday, ", @firstName ,"!</h1>"))

else 

    output(concat("<h1>Today's Birthdays</h1>"))

    if @rowCount > 0 then

      set @birthdayCount = 0

      for @i = 1 to @rowCount do

        var @firstName, @birthDate, @today, @todayMonth, @todayDay, @birthDate, @birthMonth, @birthDay
        set @row = row(@rows,@i) 
        set @firstName = field(@row,"firstName")
        set @birthDate = field(@row,"birthDate")

        set @birthMonth = datePart(@birthDate, "M")
        set @birthDay = datePart(@birthDate, "D")    

        if @todayMonth == @birthMonth and @todayDay == @birthDay then
          output(concat("<br>", @firstName))
          set @birthdayCount = add(@birthdayCount,1)
        endif

      next @i

    endif 

    if @birthdayCount == 0 then 
        output(concat("<br>No birthdays today"))
    endif

endif 

]%%

EDIT: If you don't care about personalized content when it's the recipient's birthday then you can simplify it like this:

%%[

var @rows, @row, @rowCount, @numRowsToReturn, @lookupValue, @i, @birthdayCount, @birthday, @firstName

set @numRowsToReturn = 0 
set @rows = LookupOrderedRows("Employees",@numRowsToReturn,"FirstName asc, LastName asc","lookupKey", "1")
set @rowCount = rowcount(@rows)
set @today = now(1)
set @todayMonth = datePart(@today, "M")
set @todayDay = datePart(@today, "D")

output(concat("<h1>Today's Birthdays</h1>"))

if @rowCount > 0 then

  set @birthdayCount = 0

  for @i = 1 to @rowCount do

    var @firstName, @birthDate, @today, @todayMonth, @todayDay, @birthDate, @birthMonth, @birthDay
    set @row = row(@rows,@i) 
    set @firstName = field(@row,"firstName")
    set @birthDate = field(@row,"birthDate")

    set @birthMonth = datePart(@birthDate, "M")
    set @birthDay = datePart(@birthDate, "D")    

    if @todayMonth == @birthMonth and @todayDay == @birthDay then
      output(concat("<h1>Happy Birthday, ", @firstName ,"!</h1>"))
      set @birthdayCount = add(@birthdayCount,1)
    endif

  next @i

endif 

if @birthdayCount == 0 then 
    output(concat("<br>No birthdays today"))
endif


]%%

Reference

  • hey @Adam Spriggs, correct me if I am wrong here, your code will retrieve the names of employees whose birthday is today right? Each employee (whose birthday is today) will receive a personalised (with his/her image and name) email and these emails will go out to everyone in the organization(so everyone can know whose birthday it is today). My challenge lies in limiting personalisation to those records whose birthday is today. Let me know if you need anything else. – a_ballal Oct 23 '18 at 13:47
  • Updated my answer. My thought was that you'd send an email daily to the entire employees list. If there were any birthdays today, they'd be listed in the email using the scripting above. If the recipients birthday is birthday is today, then display an alternate message. – Adam Spriggs Oct 23 '18 at 14:22
  • Thanks @Adam Spriggs. Is it possible to display "Happy birthday, @firstName" to all the employees without applying personlisation to those whose birthday is not today? For example, "Happy birthday, Jack" to all 100 employees (Only Jack has his birthday today) – a_ballal Oct 23 '18 at 14:32
  • Updated my answer to include a simplified version. – Adam Spriggs Oct 24 '18 at 11:10
  • Hey @Adam, is there a way to send a separate email to everyone (including those who have birthday)? – a_ballal Oct 24 '18 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.