dbTalk Databases Forums  

How to do a mass change in the email specified in DTS: Send Mail T

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss How to do a mass change in the email specified in DTS: Send Mail T in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SQL Junior
 
Posts: n/a

Default How to do a mass change in the email specified in DTS: Send Mail T - 07-19-2005 , 06:57 AM






for DTS PackageHi

I have created many DTS Packages that use Send Mail Task to send email to
abc (AT) test (DOT) com, how can I change them to abc (AT) test1 (DOT) com without manually
changing it (too tedious). Is there any like replace function or utility for
DTS Package that can replace test.com to test1.com.

Thanks for any advice

Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: How to do a mass change in the email specified in DTS: Send Mail T - 07-20-2005 , 02:23 PM






In message <457E1827-A22C-41E8-9578-3FB70B4AC976 (AT) microsoft (DOT) com>, SQL
Junior <SQL (AT) Junior (DOT) ?.microsoft.com.invalid> writes
Quote:
for DTS PackageHi

I have created many DTS Packages that use Send Mail Task to send email to
abc (AT) test (DOT) com, how can I change them to abc (AT) test1 (DOT) com without manually
changing it (too tedious). Is there any like replace function or utility for
DTS Package that can replace test.com to test1.com.

Thanks for any advice

Write some code like this, (not checked).

Enumerate packages, loading each one. Enumerate tasks, looking for send
mail tasks. Grab the custom task object and set the to address.


Dim oDTSApp As DTS.Application
Dim oPkgSQLServer As DTS.PackageSQLServer
Dim oPkgInfos As DTS.PackageInfos
Dim oPkgInfo As DTS.PackageInfo
Dim oPkg As DTS.Package2
Dim oTask As DTS.Task2
Dim oMailTask As SendMailTask

' Enumerate Packages
Set oDTSApp = New DTS.Application
Set oPkgSQLServer = oDTSApp.GetPackageSQLServer("SourceServer", "",
"", DTSSQLStgFlag_UseTrustedConnection)
Set oPkgInfos = oPkgSQLServer.EnumPackageInfos("", True, "")

' Loop through Packages
Set oPkgInfo = oPkgInfos.Next
' "Column does not exist" error on SQL 7.0 because sysdtspackages
lacks packagetype column

Do While Not oPkgInfos.EOF
Set oPkg = New DTS.Package2

' Load the Pkg
oPkg.LoadFromSQLServer "SourceServer", "", "",
DTSSQLStgFlag_UseTrustedConnection, "", "", "", oPkgInfo.Name

' Change SQL Connections
For Each oTask In oPkg.Tasks
If oTask.CustomTaskID = "DTSSendMailTask" Then
Set oMailTask = oTask.CustomTask
oMailTask.ToLine = "spam (AT) sqldts (DOT) com"
End If
Next

' Save the Pkg
oPkg.SaveToSQLServer "DestServer", "", "",
DTSSQLStgFlag_UseTrustedConnection

oPkg.UnInitialize

Set oPkgInfo = oPkgInfos.Next
Loop


' Clean Up
Set oMailTask = Nothing
Set oTask = Nothing
Set oPkg = Nothing
Set oPkgInfo = Nothing
Set oPkgInfos = Nothing
Set oPkgSQLServer = Nothing
Set oDTSApp = Nothing

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.