Saturday, August 17, 2013

Send Greetings to Multiple Mails from Excel in SQL Server

I am inspire to write this blog on the day of Ramzan when I want to send multiple greetings to my friends, family and others. I thought to create script which will read email IDs from excel and send Greeting to all of them.
We have to follow below steps to configure this process.
  1. Create Error_Log Table (Check blog http://www.sqlscientist.com/2013/07/error-logging-and-alerts.html)
  2. Create Greeting table
    1. Columns
      1. GreetingName
        1. This is unique name to identify greeting which we will send to all email addresses.
      2. FromName
        1. This will be written as from clause in email  body.
      3. FromMail
        1. This will be use your from email address.
      4. ToMailListFilePath
        1. This is path of excel which will contain list of name with their email ids.
      5. Subject
        1. This is subject of your greeting.
      6. Message
        1. This is message for your greeting.
      7. GreetingImgUrl
        1. This is greeting image url hosted on some server.
  3. Insert Greetings to dbo.Greeting table.
  4. Create procedure dbo.cp_Send_Greeting with parameter GreetingName.
  5. Execute procedure dbo.cp_Send_Greeting. Below is greeting mail.
image
Below are the scripts to download.
  1. Send Greetings to multiple emails.sql
Below is sample document to use it.
  1. GreetingMailList.xlsx

No comments:

Post a Comment