March 16, 2004 at 6:55 am
I have a DTS Package that exports data from a table to a fixed length file. I want this DTS Package to have the intelligence to;
1. Name the file witht the current data and then a string concatenated to it.
2. E-mail the file, once created to a few people.
I believe that I probably need to utilize the ActiveXScript to control this, but quite honestly I'm a bit confuse with it.
Could somone please let me know the process I need to follow to make this happen.
Thanks in advance.
st
March 16, 2004 at 11:03 am
FilesystemObject can do the rename.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtoriVBScript.asp
Include this in an active X script.
For the email, I use ASPEmail from persits (http://www.aspemail.com/) with this code:
Function Main()
Set Mail = CreateObject("Persits.MailSender")
Mail.Host = "mail.mydomain.com"
'put the webmaster address here
Mail.From = "webmaster@mydomain.com"
'The mail is sent to the address entered in the previous page.
'Mail.AddAddress "sjones@sqlservercentral.com"
end if
'Enter the subject of your mail here
Mail.Subject = "Current Schedules"
'This is the content of thr message.
Mail.Body = "Here is all the current Schedules for as of " & now
' Add the attachment
Mail.AddAttachment "c:\Daily_All_Current_Schedule.xls"
'this sets mail priority.... 0=low 1=normal 2=high
Mail.Priority = 1
'Send the email!
Mail.Send
Main = DTSTaskExecResult_Success
End Function
March 16, 2004 at 11:29 am
Steve, I went to the site you supplied but there was no code. All I see is the users guide. Are you saying I should look up the filesystemobject?
Thanks for your help.
st
March 17, 2004 at 1:27 am
Hi,
0. Excuse my bad english (no native english speaker)
1. Renaming the File
Look at the methods of the object
2. Sending Email
To send an email I´m using "Email Task" at the end of the workflow of the DTS package. The information about the attachment path, email adress, subject, etc. is stored into "global variables" (using ActiveX Task to set them). After setting the variables, they are mapped by "Dynamic Properties" to the properties of the "Email Task".
The only "problem" is, that you need to install a MAPI Client and you cannot choose an arbitrary email sender.
Best regards
WiWo
March 17, 2004 at 1:41 am
Try this one:
declare @outfile varchar(255)
declare @cmdshell varchar(255)
declare @msgsubject varchar(255)
set @outfile = 'd:\path\QryResult_' + convert(varchar(6), getdate(), 12) + '.asc'
set @cmdshell = 'rename d:\path\yourfile.asc ' + @outfile
exec xp_cmdshell @cmdshell
set @msgsubject = 'This is the Query result for ' + convert(varchar(10), Getdate() , 102)
exec xp_sendmail @recipients = 'a@company.com; b@company.com',
@copy_recipients = 'c@company.com',
@query = 'select GetDate()',
@subject = @msgsubject,
@attachments = @outfile,
@attach_results = 'false'
Matthias
March 17, 2004 at 2:06 am
Hello,
Matthias solution works also fine.
I´ve implemented it once similar, but had some problems with xp_cmdshell and file access to Novell Server and running the packeges sheduled.
So I decided to use ActiveX in DTS to avoid those problems.
GR
March 17, 2004 at 2:27 am
Was bedeutet WiWo?
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply