I've been able to export the report to an Excel file, but I'm having trouble figuring out how to Encrypt the new file. Below is the code in my export script task. Is it possible to add the encryption command to this script task, or will I have to create a new task? If so, what type of task do I need to create? Thanks again!
Protected Sub SaveFile(ByVal url As String, ByVal localpath As String)
Dim loRequest As System.Net.HttpWebRequest
Dim loResponse As System.Net.HttpWebResponse
Dim loResponseStream As System.IO.Stream
Dim loFileStream As New System.IO.FileStream(localpath, System.IO.FileMode.Create, System.IO.FileAccess.Write)
Dim laBytes(256) As Byte
Dim liCount As Integer = 1
'Try
loRequest = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
loRequest.Credentials = New System.Net.NetworkCredential(Dts.Variables("varSSRS_LOGIN").Value.ToString(), Dts.Variables("varSSRS_PASSWORD").Value.ToString(), Dts.Variables("varSSRS_DOMAIN").Value.ToString())
loRequest.Timeout = 600000 'timeout 15 minutes
loRequest.Method = "GET"
loResponse = CType(loRequest.GetResponse, System.Net.HttpWebResponse)
loResponseStream = loResponse.GetResponseStream
Do While liCount > 0
liCount = loResponseStream.Read(laBytes, 0, 256)
loFileStream.Write(laBytes, 0, liCount)
Loop
loFileStream.Flush()
loFileStream.Close()
'Catch ex As Exception
'End Try
End Sub
Public Sub Main()
Dim url As String
Dim outpath As String
outpath = Dts.Variables("varDestinationPath").Value.ToString + Dts.Variables("varReportName").Value.ToString() + " - " + Format(Now, "yyyyMMdd") + ".xls"
url = Dts.Variables("varSSRS_URL").Value.ToString() + "?%2fReports%2fCaseSmart%2f" + Dts.Variables("varReportName").Value.ToString() + "&rs:Command=Render&rs:Format=EXCEL"
SaveFile(url, outpath)
Dts.TaskResult = ScriptResults.Success
End Sub