Quantcast
Channel: Questions in topic: "ssis"
Viewing all articles
Browse latest Browse all 813

Package script task failing

$
0
0
I'm stumped with a package issues. I have a script task that runs to send XML email. I can run the package from within BIDS using my network account, SQLSupport network account. When I use SQL.Service network account, which is what SQL Agent uses, the package fails on the Script Task. When I look at the Execution Results all i see is ! Error: The script returned a failure result. X Task Script Task failed. But when I run this package under my own user account and the SQL Support account, this works fine. The Script Task is the below: ' Microsoft SQL Server Integration Services Script Task ' Write scripts using Microsoft Visual Basic 2008. ' The ScriptMain is the entry point class of the script. Imports System Imports System.Data Imports System.Math Imports System.Net.Mail Imports Microsoft.SqlServer.Dts.Runtime _ _ Partial Public Class ScriptMain Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase Enum ScriptResults Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure End Enum Public Sub Main() Try Dim varHTMLMail As MailMessage Dim varSMTPClient As SmtpClient Dim varMailBody As String = String.Empty Dim varAddresses As String = String.Empty Dim varAddressesBCC As String = String.Empty varMailBody = Dts.Variables("varHTML").Value.ToString varAddresses = Dts.Variables("varMailTo").Value.ToString varAddressesBCC = Dts.Variables("varMailBCC").Value.ToString ' your exchange/email server may require the 'from' address below to be a valid address varHTMLMail = New MailMessage("SQLSupport@company.com", varAddresses, "Products received in Warehouse today!", varMailBody) varHTMLMail.Bcc.Add(varAddressesBCC) varHTMLMail.IsBodyHtml = True varSMTPClient = New SmtpClient("mail.company.com") varSMTPClient.UseDefaultCredentials = True varSMTPClient.Send(varHTMLMail) Dts.TaskResult = ScriptResults.Success Catch ex As Exception 'MsgBox(ex.Message) Dts.Log("Email Script Error " & ex.Message, 0, Nothing) Dts.TaskResult = ScriptResults.Failure End Try End Sub End Class What am I overlooking?

Viewing all articles
Browse latest Browse all 813

Trending Articles