Solved To get the current date in start of the file

June 3, 2013 at 10:08:32
Specs: Windows 7

Please help me to write the current date 6/3/2013 in the header of the file in below code.
Filename.txt.

Const SMTPServer = "mail.xxx.com"
Const Recipient = "suhail_abbas@xxx.com"
Const Cc = "suhail_abbas@xxx.com"
Const From = "suhail_abbas@xxx.com"
Const Subject = "Test email"
Const Message = "Listing of today's claim batch ID's and count is attached. Total Count: "
Const fileName = "Filename.txt"
ConnectString = "Server=myServerName\myInstanceName;Database=myDataBase" & _
";User Id=someUserID" & _
";Password=somePassword"
Const FileQuery = "Exec rpt_XC_BUF_SUM"
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.CommandText = FileQuery
Set rs = com.Execute
rs.MoveFirst : Set outFile = fso.OpenTextFile(fileName, 2, True)
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

com.CommandText = SummaryQuery
Set rs = com.Execute
rs.MoveFirst
body = Message & rs(0)

GenericSendmail SMTPserver, From, Recipient, Subject, body, fso.GetAbsolutePathName(fileName)
WScript.Quit

Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message, Attachment)
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


See More: To get the current date in start of the file

Report •


#1
June 3, 2013 at 10:20:00
First of all, you should have tacked this onto your existing thread.
Second of all, what header?

How To Ask Questions The Smart Way


Report •

#2
June 3, 2013 at 10:43:35
Sorry for not tracking in existing thread.
Header is top of the file.
For example im taking the result of the query FileQuery = "Exec rpt_XC_BUF_SUM"
into a file. I want Current date on top of the file.

For eg..

6/3/2013

H1131270 3255
H2131273 931
H3131270 853
H4131272 2123
H5131273 3731
H6131270 1985


Report •

#3
June 3, 2013 at 11:19:41
✔ Best Answer
Next question: Does this script return the current date in the desired format? Make sure you test it on the system that'll run the db query script.
WScript.Echo Date

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
June 4, 2013 at 02:51:28
Hi Razor,

I got it.. Thank you so much for your help


Report •

Ask Question