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  


9 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