Firstly :
I want to execute the SP and get the resultset in the attachement for mail.
SP name : Exec rpt_XC_BUF_SUM
DB : fi4_xc_prod
Server : FACETSRPT\FACETS
I want to capture the resultset of above SP into the txt file to be attached in mail.
Secondly : I want to run the below query and capture the result set (that is count) into the Body of the mail.
DB : fi4_xc_prod
Server : FACETSRPT\FACETS
Query : select count(*) from fi4_xc_prod.dbo.XC_BUF where TBL_ORDER_ID=’C’
The body of the mail shoulde be like :
Listing of today’s claim batch ID’s and count is attached. Total Count: (From above query).
The below is the mail script i have :
SMTPServer = “mail.xxx.com”
Recipient = “suhail_abbas@xxx.com”
Cc = “suhail_abbas@xxx.com”
From = “suhail_abbas@xxx.com”
Subject = “Test email”
Message = “Listing of today’s claim batch ID’s and count is attached. Total Count: (From above query)”
‘attachment = Here the attachment from the above SP result set. It should be text file
GenericSendmail SMTPserver, From, Recipient, Subject, Message
Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)
set msg = WScript.CreateObject(“CDO.Message”)
msg.From = From
msg.To = Recipient
msg.Cc = Cc
msg.Subject = Subject
msg.TextBody = Message
‘msg.AddAttachment attachment
msg.Configuration.Fields (“http://schemas.microsoft.com/cdo/configuration/smtpserver”) = SMTPServer
msg.Configuration.Fields(“http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
msg.Configuration.Fields.Update
msg.Send
End Sub
One more help on this. Im taking the resultset of the query in txt file. im using the below code.
Const fileName = “ID_Cards_New_Individual.txt”
ConnectString = “Driver={SQL Server};Server=FATEST;Database=fa4_glhp_test”
Const FileQuery = “Exec ID_Cards_New_Individual ’04/15/2013′”
‘Const SummaryQuery = “select count(*) from fi4_xc_prod.dbo.XC_BUF where TBL_ORDER_ID=’C'”
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set com = CreateObject(“ADODB.Command”)
com.ActiveConnection = ConnectString
com.CommandTimeout = 90
com.CommandText = FileQuery
Set rs = com.Execute
rs.MoveFirst : Set outFile = fso.OpenTextFile(fileName, 2, True)
‘outFile.WriteLine(Date)
Do Until rs.EoF
For Each f In rs.Fields
line = Line & “,” & f
Next ‘f
outFile.WriteLine Mid(line, 2)
rs.MoveNext : line = “”
Loop
outFile.Close
The result is coming in the below format.
0000003956,200344086,MARY,ENGLAND,
I want the result to come like below with double quotes
“0000003956”,”200344086″,”MARY”,”ENGLAND”,
Please help…