Read Subject,Reciptient and Body from SQL Server Table and Send Email by Using Send Mail Task - SQL Server Integration Services(SSIS) Tutorial

Scenario:

Let's say we have a table which store Email To , Email From , Subject and Body of emails those we need to send on daily basis. We want to design an SSIS Package that runs on schedule and send email for each of the record that is stored in the Table.

Solution:

To solve above scenario, we will be using following components of an SSIS Package
  1. Read all the records from a table and stored in Object type variable by using Execute SQL Task
  2. Loop through Object type variable by using For-each Loop Container and store values in variables
  3. Write Expressions in Send Mail Task
CREATE TABLE dbo.Email (
    id INT identity(1, 1)
    ,EmailFrom VARCHAR(100)
    ,EmailTo VARCHAR(100)
    ,Subject VARCHAR(100)
    ,Body NVARCHAR(MAX)
    )
GO

INSERT INTO dbo.Email (
    Emailfrom
    ,EmailTo
    ,Subject
    ,Body
    )
VALUES (
    'aamirsqlage@gmail.com'
    ,'techbrotherssqlage@gmail.com'
    ,'Test Subject1'
    ,'

Hi

This is email for Test1

Thank you

Tech Brothers'
    )

INSERT INTO dbo.Email (
    Emailfrom
    ,EmailTo
    ,Subject
    ,Body
    )
VALUES (
    'aamirsqlage@gmail.com'
    ,'techbrotherssqlage@gmail.com'
    ,'Test Subject2'
    ,'

Hi

This is email for Test2

Thank you

Tech Brothers'
    )

INSERT INTO dbo.Email (
    Emailfrom
    ,EmailTo
    ,Subject
    ,Body
    )
VALUES (
    'aamirwarraich2001@gmail.com'
    ,'techbrotherssqlage@gmail.com'
    ,'Test Subject3'
    ,'

Hi

This is email for Test3

Thank you

Tech Brothers'
    )

SELECT EmailFrom
    ,EmailTo
    ,Subject
    ,Body
FROM dbo.Email




Read Email information from SQL Server Table and Send Email by using Send Mail Task in SSIS Package - SSIS Tutorial



  Related Posts/Videos on Send Mail Task  


16 comments:

  1. The best Psoriasis creams are steroid creams, they help in the treatment of most skin condition. clenbuterol for sale

    ReplyDelete
  2. Fantastic, Your post is an excellent example of why I keep coming back to read your excellent quality commentary…. see here now

    ReplyDelete
  3. We'll discuss co-distributing and we'll examine roundabout mailing (you'll figure out how to get individuals to pay you money to mail their brochures for them!). millions of leads

    ReplyDelete
  4. Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. best testosterone supplements

    ReplyDelete
  5. Your eating routine ought to likewise incorporate satisfactory fiber and water so your stomach related framework/kidneys can adapt to the extra protein/carbs you're placing into your body. best place to buy ostarine

    ReplyDelete
  6. Why do only so much written on this subject? Here you see more. cbd cream for pain

    ReplyDelete
  7. People that currently have health insurance are going to be transitioned into these new plans sometime in 2014. So the insured will be directly affected by this because the health plans they have today are going away, and they will be mapped into a new ObamaCare plan in 2014. do bananas cause gas

    ReplyDelete
  8. In fact, some of the carriers are now saying they anticipate that up to 50% of small groups with 10 or fewer employees are going to drop their health insurance plan sometime between 2014 and 2016. 50 mg cbd capsules

    ReplyDelete
  9. Interestingly you write, I will address you'll find exciting and interesting things on similar topics. Glownar

    ReplyDelete
  10. Extremely instructive post ! There is a great deal of data here that can enable any business to begin with a fruitful interpersonal interaction campaign ! Infinix Hot 9 Pro Price

    ReplyDelete
  11. This is a great post I seen because of offer it. It is truly what I needed to see seek in future you will proceed after sharing such a magnificent post. مسلسلات رمضان 2022

    ReplyDelete
  12. On my website you'll see similar texts, write what you think. Satta king 786

    ReplyDelete
  13. If you win the game then you can win 80 to 90 times your amount. If you failed to win then all your amounts will be gone. There are various types of games available in Satta King. Choose accordingly and see Satta king fast result. Many people have tried their luck and they won the game.

    ReplyDelete
  14. Great article. I love your writing style. It's inspirational and I truly appreciate it. Visit my website.
    Black satta king

    ReplyDelete
  15. What is Satta King Online Site all about?
    The Satta king online site is one of the top websites in the Satta King market. We all update the results of the Satta King game very quickly which is the reason for the rapid growth of our viewers. We truly thank all our visitors for making us the leading website of Satta King.

    ReplyDelete
  16. A decent blog dependably concocts new and energizing data and keeping in mind that understanding I have feel that this blog is truly have each one of those quality that qualify a blog to be a one. One Plus 8 Pro Price

    ReplyDelete