dbTalk Databases Forums  

Conditional Email If Table values not null

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


Discuss Conditional Email If Table values not null in the microsoft.public.sqlserver.dts forum.



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

Default Conditional Email If Table values not null - 07-06-2006 , 08:24 PM






Hi

I have been cracking my skull on sending a conditional email only if
values in an Excel spreadsheet are present. I have already queried the
database to export (via DTS) only interested values to the spreadsheet.
I need help in getting the syntax and placement of the IF statements
correct.
Also, if there is some way to only check whether if the query is not
null instead of the Excel spreadsheet, that would be fantastic as well.
Thanks!


************************************************** ********************
' 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")

If xl_spreadsheet.table.value(null) --------------------> Is this the
correct placement and syntax??

With cdoMessage
Set .Configuration = cdoConfig
.From = "repor... (AT) acme (DOT) com"
.To = "mongomadn... (AT) acme (DOT) com"
.Subject = "Automated Report For Today"
.TextBody = "We have found significant errors for your
correction."
.AddAttachment ( "\\mongoReport.xls")
.Send
End With

else ----------------------->Is this the correct placement and syntax??


With cdoMessage
Set .Configuration = cdoConfig
.From = "repor... (AT) acme (DOT) com"
.To = "mongomadn... (AT) acme (DOT) com"
.Subject = "Automated Report For Today"
.TextBody = "There are no errors for correction today."

.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing


Main = DTSTaskExecResult_Success


End Function


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.