Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Convert Activex Scripts to VB / C# Script tast for SQL2008

$
0
0

I am converting a sql 2005 server to 2008.  I have an old active x script which i need to convert to a script task for ssis...

I am not familar with VB/C# scripting so I do not know how to convert this for use in 2008.

When Run i receive this error " An error occurred while adding the managed SSIS type library to the script host. Verify that the DTS 2000 runtime is installed".  I believe we want to avoid invoking the legacy functionality so converting the scripts at this point would be better.

'**********************************************************************
'  Visual Basic ActiveX Script
'**********************************************************************

Function Main()
	Dim strTo
	Dim strCC
	Dim strSubject
	Dim strBody

	'Construct the subject and body and set the attachment path
	strSubject = "Validation #" + CStr(DTSGlobalVariables("VAL_ID").Value) + " (" + CStr(DTSGlobalVariables("ErrorCount").Value) + "): " + DTSGlobalVariables("VAL_NAME")
	strBody = "Description:<br />" + vbCRLF + Replace(DTSGlobalVariables("VAL_DSCR").Value, "''", "'") + vbCRLF + vbCRLF + "<br /><br />Suggestions:<br />" + vbCRLF + Replace(DTSGlobalVariables("VAL_WEB_NOTES").Value, "''", "'")
	strAttachmentPath = DTSGlobalVariables("FileAttachmentPath").Value

	'Construct the address lists depending on if there were errors
	If DTSGlobalVariables("ErrorCount").Value = 0 Then
		strTo = DTSGlobalVariables("EmailAddyNoErrorsTo").Value
		strCC = DTSGlobalVariables("EmailAddyNoErrorsCC").Value
	Else
		strTo = DTSGlobalVariables("EmailAddyErrorsTo").Value
		strCC = DTSGlobalVariables("EmailAddyErrorsCC").Value
	End If

	'If there's someone to send an email to, do so.
	If Len(strTo) > 0 Then
		Call SendSMTPEmail(strTo, strCC, strSubject, strBody, strAttachmentPath)
	End If

	Main = DTSTaskExecResult_Success
End Function


'***********************************************************************************************************************************************************
'This function sends the email
'***********************************************************************************************************************************************************
Function SendSMTPEmail(ToAddresses, CCAddresses, SubjectText, BodyText, AttachmentPath)


	Dim iMsg
	Dim iConf
	Dim Flds
	
	Const cdoSendUsingPort = 2
	
	Set iMsg = CreateObject("CDO.Message")
	Set iConf = CreateObject("CDO.Configuration")
	Set Flds = iConf.Fields
	With Flds
		.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
		.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
		.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
		.Update
	End With
	With iMsg
		Set .Configuration = iConf
		.To = ToAddresses
		.CC = CCAddresses
		.From = "OPSValidator@somewhere.com"
		.Subject = SubjectText
'		.TextBody = BodyText
		.HTMLBody = BodyText
		.AddAttachment (AttachmentPath)
		.Send
	End With
	Set iMsg = Nothing
	Set iConf = Nothing
	Set Flds = Nothing

End Function


KDW



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>