Showing posts with label attachment. Show all posts
Showing posts with label attachment. Show all posts

Sunday, March 11, 2012

Dynamic File Name for Attachment

hi

I am encountering the same problem above and I did exacly as described . But it is not working.

I must send emails every month with dynamically named files as attachments.
The files are named according to the date on which they are generated.
For example on the first of November 2007, the file will be named myfile_1_11_2007.

I have created a variable called DynamicFileName with package scope, data type string and default value: d:\\tests\\

In "Send Mail Task Editor" Dialog Box, I have specified the following:

smtpConnection: smtptest.server.com
From :nemo@.smtptest.server.com
To: nemo@.smtptest.server.com
Subject: Dynamic File Email
MessageSourceType: Variable
MessageSource: blank
Priority: blank
Attachments: blank

In Expressions, I have specified:

FileAttachments: @.[User:Big SmileynamicFileName] + "myfile_" + (DT_STR, 4, 1252) DAY( GETDATE() ) + "_" + (DT_STR, 4, 1252) MONTH( GETDATE() ) + "_" + (DT_STR, 4, 1252) YEAR ( GETDATE() ) + ".csv"

When I execute the package, I get the following errors:
--
Error at Send Mail Task [Send Mail Task]: Either the file "d:\\tests\\myfile_1_7_2007.csv" does not exist or you do not have permissions to access the file.

Error at Send Mail Task: There were errors during task validation.

Of course, the file does not exist. It will exist at tun-time. How can I tell the Send Mail Task to use a filename that is dynamic ?

By the way, once I have specified the code for FileAttachments, on trying to edit the Send Mail Task Properties, I can see that the Atachments field has been set to "d:\tests\myfile_1_7_2007.csv by itself: I never typed it there !! It seems that the task executes the code even before it is run. If I remove the attachment path manually, on running the dts, I get an error saying that "either the file does not exist or you do not have permission to access the file.

I would be most grateful if anyone could be of help

thanks

I am trying to work this out here. Have you checked that the file gets dynamically created BEFORE your Send Main task?

Sounds silly I know, but put a break point on the component/container that is generating the file and double check on your C drive to ensure it does actually exist.

Also d:\\tests\\myfile_1_7_2007.csv doesn't look right to me.

The UNC syntax for Windows systems is : \\computername\sharedfolder\resoyrce

Therefore I think you need to check your expression evaluates correctly!

Good luck!

|||

Another thing to think about is, does the account you are running the package from have access to the folder you are trying to write to? (I also agree with the statement above that you should be using the UNC path)

Have you tried checking the delayvalidation property for the send mail task?

|||EWishdahl, let me give u a kiss!!! Muah! Muah!The delayvalidation property was the answer!!!I hope you are a girl!!Thanks !!!!!|||

Negative... no man kisses please ...

Glad I could help though (remember to mark all applicable answers)

Eric Wisdahl

Friday, March 9, 2012

Dynamic Email Attachment Name

I have a report subscription set up to email a report via a Data
Driven Subscription. I have been asked to make the file name unique
with a date stamp in the email message. I do not see the FileName
field as one of the options in the email delivery. I know that I can
do this via the FileShare extension, but this report is going to an
outside company that does not have access to our file share.
Is there any way to dynamically set the file name in the email
attachment?On Dec 14, 5:06 pm, dachrist <dachris...@.gmail.com> wrote:
> I have a report subscription set up to email a report via a Data
> Driven Subscription. I have been asked to make the file name unique
> with a date stamp in the email message. I do not see the FileName
> field as one of the options in the email delivery. I know that I can
> do this via the FileShare extension, but this report is going to an
> outside company that does not have access to our file share.
> Is there any way to dynamically set the file name in the email
> attachment?
Probably the best option you have for emailing a report with a dynamic
naming convention is to use the Reporting Services Web Service (http://
msdn2.microsoft.com/en-us/library/
microsoft.wssux.reportingserviceswebservice.rsexecutionservice2005.reportexecutionservice.render.aspx )
to call, export and dynamically name the report. Then use the built in
functionality of the .NET framework via a custom ASP.NET/Exe
application to email the reports (using System.Net.Mail). Hope this
helps.
Regards,
Enrique Martinez
Sr. Software Consultant