Solved

SSIS: Using User variables in Send Mail Task

Posted on 2013-12-06
3
1,953 Views
Last Modified: 2016-02-10
Hi there,

I am trying to build an email message using Send Mail task but taking some of the message in the email from two user defined variables that I have set in Execute SQL Task (i.e. configuring Result Set to relate my user defined variables to the column names where I'm reading the values from).

The expression I've tried to build in the Send Mail task is below:

"The xxxx xxxxxx report was successfully processed with an open date of: " + @[User::FileDate2] + "and an open time of: " + @[User::FileTime2]

Open in new window


But I get the error is

"The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created."

However, it seems to work if I just select the user variable i.e. if I just choose User::FileDate2 then I get the value I'm looking for but obviously no messages around what it means just a date.

What can I do to get the email message I'm looking for?

Thanks,

Segun
0
Comment
Question by:onesegun
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39700933
Try putting the body of the message into its own variable, which will allow you to include other variables as part of its definition. Then use that to populate your mail task.
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 39713507
Are you sure both variables are on package-level scope?  You can check that from the Variables window where one of the columns mentions the scope.
0
 

Author Closing Comment

by:onesegun
ID: 39714007
Seems like the only way is to join the variables together at the script task level i.e. the message, the time variable and the date variable into one long variable and then use that in the Send Mail Task.

Thanks
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

In couple weeks ago, I encountered an extremely difficult problem while deploying 2008 SSIS packages to a new environment (SQL Server 2014 standard).  My scenario is: We have one C# application that is calling 2008R2 SSIS packages to load text fi…
In this article I will describe the Detach & Attach 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 is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now