Excel file name issue in send mail task using SSIS

  • I have a package which is creating a excel file 'ExcelName.xls' and storing in 'E:\Reporting\Delivered_Reports'. Now I have to attach this report using send mail task and send it to given mail id. To achieve this I have configured the send mail task and in Expression Builder, I have selected the below expression:

    "E:\\Reporting\\Delivered_Reports\\ExcelName_"+

    ((DT_WSTR,4)Year(@[System::StartTime]))+

    RIGHT("0"+((DT_WSTR,2)Month(@[System::StartTime])),2)+

    RIGHT("0"+((DT_WSTR,2)Day(@[System::StartTime])),2)+".xls"

    I need file name should be 'ExcelName_20150601' where suffix is the current date. But I recieve file which name is 'ExcelName', which is the origional file name. Can you tell me where I am wrong?

    Thanks in advance

  • manoj.ramaiah (6/1/2015)


    I have a package which is creating a excel file 'ExcelName.xls' and storing in 'E:\Reporting\Delivered_Reports'. Now I have to attach this report using send mail task and send it to given mail id. To achieve this I have configured the send mail task and in Expression Builder, I have selected the below expression:

    "E:\\Reporting\\Delivered_Reports\\ExcelName_"+

    ((DT_WSTR,4)Year(@[System::StartTime]))+

    RIGHT("0"+((DT_WSTR,2)Month(@[System::StartTime])),2)+

    RIGHT("0"+((DT_WSTR,2)Day(@[System::StartTime])),2)+".xls"

    I need file name should be 'ExcelName_20150601' where suffix is the current date. But I recieve file which name is 'ExcelName', which is the origional file name. Can you tell me where I am wrong?

    Thanks in advance

    Is there a reason for the doubled back-slashes (\\) ?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Try it with GETDATE() instead of @[System::StartTime].

    MWise

  • Hi,

    I have tried with GETDATE() also, but it did not resolve my issue....

  • Which property are you assigning this expression to?

  • This expression "E:\\Reporting\\Delivered_Reports\\ExcelName_"+

    ((DT_WSTR,4)Year(GETDATE()))+

    RIGHT("0"+((DT_WSTR,2)Month(GETDATE())),2)+

    RIGHT("0"+((DT_WSTR,2)Day(GETDATE())),2)+".xls"

    Evaluates to E:\Reporting\Delivered_Reports\ExcelName_20150602.xls. I've confirmed that in a test package and attached screen shots.

    Are you setting this to a variable? If so, make sure that the scope is the package level and that you have EvaluateAsExpression property set to TRUE, see attached screen shot.

    Then in your Send Mail Task, set the FileAttachment expression to the variable. If the file won't exist at run time, make sure DelayValidation is set to true.

    MWise

  • Hi thanks for your suggetion,

    Where we should use This expression "E:\\Reporting\\Delivered_Reports\\ExcelName_"+

    ((DT_WSTR,4)Year(GETDATE()))+

    RIGHT("0"+((DT_WSTR,2)Month(GETDATE())),2)+

    RIGHT("0"+((DT_WSTR,2)Day(GETDATE())),2)+".xls".

    In send mail task or somewhere else?

    Thanks for your time

  • manoj.ramaiah (6/3/2015)


    Hi thanks for your suggetion,

    Where we should use This expression "E:\\Reporting\\Delivered_Reports\\ExcelName_"+

    ((DT_WSTR,4)Year(GETDATE()))+

    RIGHT("0"+((DT_WSTR,2)Month(GETDATE())),2)+

    RIGHT("0"+((DT_WSTR,2)Day(GETDATE())),2)+".xls".

    In send mail task or somewhere else?

    Thanks for your time

    MWise already answered this for you:

    Then in your Send Mail Task, set the FileAttachment expression to the variable. If the file won't exist at run time, make sure DelayValidation is set to true.

    Did this not work?

    Where are you trying to use the expression?

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply