dbTalk Databases Forums  

Including yesterday's date in CDO email function

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


Discuss Including yesterday's date in CDO email function in the microsoft.public.sqlserver.dts forum.



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

Default Including yesterday's date in CDO email function - 07-05-2006 , 06:12 PM






I need to auto include yesterday's date into an emailed message
TextBody. I've tried using getdate() but it didn't work. Is there
someway to incorporate it into the function below? Help please?


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

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet

SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\mongoReport.xls")

SET xl_spreadsheet = xl_app.Workbooks.Open("mongoReport.xls")

'Run the macro

xl_app.Run("transform_macro")

xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing




sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields



.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "qarelay1"
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "reporter (AT) acme (DOT) com"
.To = "mongomadness (AT) acme (DOT) com"
.Subject = "Automated Report For Today"
.TextBody = "Your daily dose of Mongomadness Report.These reports are
for files recieved on (NEED YESTERDAY'S DATE HERE). Please do not reply
to this message, you will not get a response."
.AddAttachment ( "\\mongoReport.xls")
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing



Main = DTSTaskExecResult_Success

End Function


Reply With Quote
  #2  
Old   
Davide Rossetti
 
Posts: n/a

Default Re: Including yesterday's date in CDO email function - 07-06-2006 , 06:33 AM






Hello javathehutt,

Quote:
I need to auto include yesterday's date into an emailed message
TextBody. I've tried using getdate() but it didn't work. Is there
someway to incorporate it into the function below? Help please?

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

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\mongoReport.xls")

SET xl_spreadsheet = xl_app.Workbooks.Open("mongoReport.xls")

'Run the macro

xl_app.Run("transform_macro")

xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing
sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields

.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "qarelay1"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "reporter (AT) acme (DOT) com"
.To = "mongomadness (AT) acme (DOT) com"
.Subject = "Automated Report For Today"
.TextBody = "Your daily dose of Mongomadness Report.These reports
are
for files recieved on (NEED YESTERDAY'S DATE HERE). Please do not
reply
to this message, you will not get a response."
.AddAttachment ( "\\mongoReport.xls")
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Main = DTSTaskExecResult_Success

End Function




Dim yesterday 'As Date
Dim yesterdaystr 'As String
yesterday = DateAdd ("d" , -1 , Now() )
yesterdaystr = Year(yesterday) & "-" & Month(yesterday) & "-" & Day(yesterday)


Bye




Reply With Quote
  #3  
Old   
javathehutt
 
Posts: n/a

Default Re: Including yesterday's date in CDO email function - 07-06-2006 , 08:00 PM



Thank you much!



Davide Rossetti wrote:
Quote:
Hello javathehutt,

I need to auto include yesterday's date into an emailed message
TextBody. I've tried using getdate() but it didn't work. Is there
someway to incorporate it into the function below? Help please?

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

Function Main()

'References to Excel
dim xl_app
dim xl_Spreadsheet
SET xl_app = CREATEOBJECT("Excel.Application")

'SET xl_app = GetObject("\\mongoReport.xls")

SET xl_spreadsheet = xl_app.Workbooks.Open("mongoReport.xls")

'Run the macro

xl_app.Run("transform_macro")

xl_spreadsheet.Save

xl_spreadsheet.Close

xl_app.Quit
set xl_app = Nothing
sch = "http://schemas.microsoft.com/cdo/configuration/"

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields

.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
.Item(sch & "smtpserver") = "qarelay1"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "reporter (AT) acme (DOT) com"
.To = "mongomadness (AT) acme (DOT) com"
.Subject = "Automated Report For Today"
.TextBody = "Your daily dose of Mongomadness Report.These reports
are
for files recieved on (NEED YESTERDAY'S DATE HERE). Please do not
reply
to this message, you will not get a response."
.AddAttachment ( "\\mongoReport.xls")
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
Main = DTSTaskExecResult_Success

End Function





Dim yesterday 'As Date
Dim yesterdaystr 'As String
yesterday = DateAdd ("d" , -1 , Now() )
yesterdaystr = Year(yesterday) & "-" & Month(yesterday) & "-" & Day(yesterday)


Bye


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 - 2012, Jelsoft Enterprises Ltd.