SSIS Package To send seperate emails via SMTP with each files in a directory
That worked great. Thanks. One more question the subject line has the full path of the attached file (c:\.......\file1.txt) but I need it to be just the file name (file1) without the extension as the filename. I attempted to build the subject expression using the SUBSTRING command to say SUBSTRING([@variable],41, LEN[@variable]-4)) but I'm getting syntax errors. What's an easy way to just get the file name as the subject line. I can just the file name with the extension but I can't get rid of the extension in the subject line. Thanks Jon
January 22nd, 2011 6:57pm

I'm fairly new to SSIS packages and I need to create a package which looks at all files in a directory and sends each one separately as an email attachment via SMTP using the file name as the subject. If anyone can let me know the easiest way to do this that would be great.Also if anyone know a better way to do this outside of SQL that would also be helpful. Ex: Directory has 3 files. file1.txt, file2.txt and file3.txt. I need to send 3 emails (1 for each file) with the file as the attachment and the file name as the subject. Email 1: Attachment: file1.txt Subject: File 1 Email 2: Attachment: file2.txt Subject File 2 Email 3: Attachment: file3.txt Subject File 3 Thanks Jon
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2011 7:15pm

Use a foreach loop with file enumerator. Point the enumerator to your folder. Now the loop would run for each file in the folder. Set the foreach loop to capture just the full filepath including the name and extension and map this to a variable in ur package. Put a Send mail task in the loop and configure the attachment by using expression which has the above variable name. For the subject you need to write an expression to extract the file name from the entire path. use the expression provided in my bolg for this purpose.
January 22nd, 2011 7:22pm

Hello, You need to use Foreach loop file enumurator. Step1: Get the foreach loop in control flow, configure foreach loop for File Enumurator. here is link , how to configure it http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx http://www.sqlis.com/post/Looping-over-files-with-the-Foreach-Loop.aspx You would have the filename every time it will loop 2--get the send mail task, configure the connection manager and then double click the transformation and you will see the expressions , go to subject and in expression , get your FileName variable, so your filename will become subject http://support.microsoft.com/kb/906547 3--You will see attachment too in expression, provide the directory +FileName(variable) in expressions, so it will attach the file http://consultingblogs.emc.com/jamiethomson/archive/2008/07/11/ssis-nugget-conditionally-email-a-file-containing-error-rows.aspx 4--in EmailTo and EmailFrom you can also provide values by using variables or hard code them.
Free Windows Admin Tool Kit Click here and download it now
January 22nd, 2011 7:24pm

SUBSTRING(RIGHT(@[User::FileName],FINDSTRING(REVERSE(@[User::FileName]),"\\",1)-1),1, FINDSTRING((RIGHT(@[User::FileName],FINDSTRING(REVERSE(@[User::FileName]),"\\",1)-1)),".",1)-1) To get the file name not the expression you could use the above expression. a bit complex but This could be shortened.
January 22nd, 2011 7:53pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics