Solved

SSIS - Send Mail Task -  Multiple attachments

Posted on 2008-10-22
5
5,400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Comparison of Amazon Drive, Google Drive, OneDrive

What is Best for Backup: Amazon Drive, Google Drive or MS OneDrive? In this free whitepaper we look at their performance, pricing, and platform availability to help you decide which cloud drive is right for your situation. Download and read the results of our testing for free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

707 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