?
Solved

SSIS - Send Mail Task -  Multiple attachments

Posted on 2008-10-22
5
Medium Priority
?
5,490 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

764 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