Solved

SSIS - Send Mail Task -  Multiple attachments

Posted on 2008-10-22
5
5,206 Views
Last Modified: 2013-11-10
I have created an SSIS package that created 4 .csv files and stores them within my required location.
The files exported have an expression that allocates today's date so that each file is saved and renamed on a daily basis.

My Expression to create the File name for the various files looks like this; ( This is part of the Flat File Connection String)

"\\\\Lonbilling\\Billing\\Fraud Alert\\CLI_Spend_" + (DT_WSTR,4)DATEPART("dd",GETDATE()) + (DT_WSTR,4)DATEPART("mm",GETDATE()) +
(DT_WSTR,4)DATEPART("yy",GETDATE()) +".csv"

The Evaluated Value looks like this;
\\Lonbilling\Billing\Fraud Alert\CLI_Spend_22102008.csv

I have 4 files with slightly different names all within the same location I want to pick up and attach within an email based on the current date.

I want to use the Send mail task to email all 4 attachments within one email to my recipients within the same SSIS package.

Please can someone tell me how I can attach multiple files into the Send Mail task based on my expression ? There is a FileAttachment Expression available however I don't know the correct code to specify more than one file ?

Help would be appreciated ?
0
Comment
Question by:EHardie
  • 3
5 Comments
 
LVL 22

Expert Comment

by:PedroCGD
ID: 22777896
Check the post:
http://blogs.conchango.com/jamiethomson/archive/2006/07/03/SSIS_3A00_-Sending-SMTP-mail-from-the-Script-Task.aspx

and search for:
myHtmlMessage.Attachments.Add(New Attachment("c:\example.txt"))

use a script task in spite Send Mail task
use VB or C# code to be more flexible.

pass the c:\example.txt as SSIS global variable to the script
helped?
Regards
0
 

Author Comment

by:EHardie
ID: 22778142
Hi,

Thanks but not sure if this will work also my VB skills are non existant.
Basically I need to pick up these 4 files daily based on the naming convention and date.
So each day the mail needs to pick up the correct file e.g.FILE NAME + Current Date Stamp
So tomorrow's files will be e.g.CLI_Spend_23102008.csv
Can I script it to look this up , using the script task ?
0
 
LVL 22

Accepted Solution

by:
PedroCGD earned 500 total points
ID: 22778227
Pick up the files, you can do with ForEachLoop container in the controlflow
to send the mail is more complex... and I suggested to follow the blog post ... you dont need to make many changes...
Regards
0
 
LVL 17

Expert Comment

by:HoggZilla
ID: 22780421
Hi,
There is a simple email component you can run SQL Server 2005, so long as it is not 64 bit. XPSMTP. http://sqldev.net/xp/xpsmtp.htm This gets you your email capabilities through an execute SQL Task.
If you need to use the SendMailTask...
Attachments
Provide the file names of attachments to the e-mail message, delimited by the pipe (|) character for multiple files.
 Where are you in the process - can I give you some specific help at your current point?
0
 
LVL 22

Expert Comment

by:PedroCGD
ID: 22780630
or you can send email by a webservice as I do in my projects!
regards
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now