March 12, 2009 at 9:57 am
Hi Guys
I have a table that is going to hold email addresses for a mailing list
Eg.
MailingList:
ID, Email
1,billybob@ipadd.com
2,janef@ipadd.com
3,harryk@ipadd.com
4,evonnet@ipadd.com
I am creating a SSIS package that is going to use the email addresses in MailingList table within a ‘Send Mail Task’. I was basically going to use an ‘Execute SQL Task’ to generate the list into a variable which I would then use in the ‘ToLine’ expression for the ‘Send Mail Task’
The thing I am trying to achieve is have the following output:
billybob@ipadd.com; janef@ipadd.com; harryk@ipadd.com; evonnet@ipadd.com
I hope this all makes sense and is this possible to do?
Thanks
March 13, 2009 at 1:56 am
i created a table EmailTest with your fields.
Then i created the following code:
Declare @id int,@email varchar(100), @mail varchar(200)
set @id = 1
set @mail = ''
-- Looping through the table to pick up all EmailIds
While @id<5
Begin
Select @email = emailid from emailtest
where id = @id
set @mail = @mail + @email + ','
Set @id = @id +1
End
--Remove trailing comma
select left(@mail,len(@mail)-1) as SSISVariable
You may use the above code in the execute sql task and use resultset to populate your variable with SSISVariable.
This will give you the desired output.
Hope this Helps...
March 13, 2009 at 7:45 am
rcr69er (3/12/2009)
Hi GuysI have a table that is going to hold email addresses for a mailing list
Eg.
MailingList:
ID, Email
1,billybob@ipadd.com
2,janef@ipadd.com
3,harryk@ipadd.com
4,evonnet@ipadd.com
I am creating a SSIS package that is going to use the email addresses in MailingList table within a ‘Send Mail Task’. I was basically going to use an ‘Execute SQL Task’ to generate the list into a variable which I would then use in the ‘ToLine’ expression for the ‘Send Mail Task’
The thing I am trying to achieve is have the following output:
billybob@ipadd.com; janef@ipadd.com; harryk@ipadd.com; evonnet@ipadd.com
I hope this all makes sense and is this possible to do?
Thanks
You have to use comma (,) not semicolon to separate individual emails.
March 13, 2009 at 9:38 am
Hey Guys
Thanks for all your help!!!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply