New function to send email on layouts.