Email VBSCRIPT:在文件中查找文本,如果找到文本,则发送电子邮件日志
我目前有一个VBSCRIPT,它将获取错误日志的全部内容并通过电子邮件发送给用户,但我想对其进行修改,以便它搜索“遇到加载数据”,如果出现,则通过电子邮件发送错误。否则,不要附加日志并发送消息“加载成功”。 任何帮助都将不胜感激 错误日志的内容Email VBSCRIPT:在文件中查找文本,如果找到文本,则发送电子邮件日志,email,search,text,vbscript,Email,Search,Text,Vbscript,我目前有一个VBSCRIPT,它将获取错误日志的全部内容并通过电子邮件发送给用户,但我想对其进行修改,以便它搜索“遇到加载数据”,如果出现,则通过电子邮件发送错误。否则,不要附加日志并发送消息“加载成功”。 任何帮助都将不胜感激 错误日志的内容 2017-04-24 15:35:13,429 DEBUG [AIF]: CommData.updateWorkflow - END 2017-04-24 15:35:13,429 DEBUG [AIF]: AIFUtil.callOdiServlet
2017-04-24 15:35:13,429 DEBUG [AIF]: CommData.updateWorkflow - END
2017-04-24 15:35:13,429 DEBUG [AIF]: AIFUtil.callOdiServlet - START
2017-04-24 15:35:13,451 INFO [AIF]: EssbaseService.loadData - START
2017-04-24 15:35:13,507 DEBUG [AIF]: appId:3, appType:ESSBASE, mcFlag:false, dataLoadMethod:CLASSIC_VIA_EPMI, mDataFlowNode:LOCAL, textDataLoad:N, isFccsLoad:false, isJournalLoad:false
2017-04-24 15:35:13,508 DEBUG [AIF]: LOAD_METHOD:ESSFILE, LOAD_TYPE:DATA, EXPORT_MODE:STORE_DATA, CREATE_DRILL_REGION:false, PURGE_DATA_FILE:true, BATCH_SIZE:10000
2017-04-24 15:35:13,629 INFO [AIF]: cloudServiceType: Planning, Resolved user name for application access: epm_default_cloud_admin
2017-04-24 15:35:14,816 DEBUG [AIF]: Obtained connection to essbase cube: Finance
2017-04-24 15:35:14,818 DEBUG [AIF]: Resolved essbase rule file name for loading: AIF0069
2017-04-24 15:35:14,819 DEBUG [AIF]: Fetching rule file from essbase server for data loading: AIF0069
2017-04-24 15:35:14,824 INFO [AIF]: Starting executeDataRuleFile...
2017-04-24 15:35:14,826 DEBUG [AIF]: Locked rule file: AIF0069
2017-04-24 15:35:14,827 INFO [AIF]: Getting load buffer for ASO data load...
2017-04-24 15:35:14,828 INFO [AIF]: Initializing load buffer [1]
2017-04-24 15:35:14,828 INFO [AIF]: Successfully initialized the load buffer
2017-04-24 15:35:14,828 INFO [AIF]: Loading data into cube using data file...
2017-04-24 15:35:14,844 INFO [AIF]: purge data file: /u03/inbox/outbox/AQCONSOL_930.dat
2017-04-24 15:35:14,845 INFO [AIF]: The load buffer [1] has been closed.
2017-04-24 15:35:14,845 INFO [AIF]: **Load data encountered** the following errors:
| Error: 3303 | A99999 | "A99999","01","Functional","L000","Default Version","C10010","P0000","J00000","FY16","G00","Actual","[YearTotal].[Q1].[Jan]",100 |
2017-04-24 15:35:14,845 INFO [AIF]: Load data failed.
2017-04-24 15:35:14,846 DEBUG [AIF]: Unlocked rule file: AIF0069
2017-04-24 15:35:14,846 ERROR [AIF]: Load data failed.
2017-04-24 15:35:14,853 INFO [AIF]: EssbaseService.loadData - END (false)
2017-04-24 15:35:14,871 DEBUG [AIF]: AIFUtil.callOdiServlet - END
2017-04-24 15:35:14,871 FATAL [AIF]: Error in CommData.loadData
Traceback (most recent call last):
File "<string>", line 4769, in loadData
RuntimeError: false
fileEmail = "C:\Error.log"
intCount = 0
Set objStream = objFSO.OpenTextFile(fileEmail)
Do Until objStream.AtEndOfStream
sline = objStream.Readline
If intCount = 0 Then
objMessage.Subject = sline
Else
strMessage = strMessage & sline & vbcrlf
End If
intCount = intCount + 1
Loop
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
strMessage = strMessage & vbcrlf
objMessage.From = "test@123.com"
objMessage.To = "test@123.com"
objMessage.TextBody = strMessage
objMessage.Configuration.Fields.Item _
("Microsoft URL") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = "smtp.secureserver.net"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("Microsoft URL") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = ""
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = ""
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = 465
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = True
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = 60
objMessage.Configuration.Fields.Update
objMessage.Send
Set objStream = Nothing
'Delete File when finished
objFSO.DeleteFile fileprocesslog, True
返回一个字符串在另一个字符串中第一次出现的位置。应用它,例如,如下所示:
sSearchFor = "Load data encountered"
booFound = False
sMessageSubj = "Log file empty"
fileEmail = "C:\Error.log"
intCount = 0
Set objStream = objFSO.OpenTextFile(fileEmail)
Do Until objStream.AtEndOfStream
sline = objStream.Readline
If intCount = 0 Then
sMessageSubj = sline
Else
strMessage = strMessage & sline & vbcrlf
End If
booFound = booFound Or ( Instr( 1, sline, sSearchFor, vbTextCompare) > 0)
intCount = intCount + 1
Loop
objStream.Close
Set objMessage = CreateObject("CDO.Message")
objMessage.From = "test@123.com"
objMessage.To = "test@123.com"
objMessage.Subject = sMessageSubj
If booFound Then
objMessage.AddAttachment fileEmail
strMessage = strMessage & vbcrlf
Else
strMessage = "Load was successful" & vbcrlf
End If
objMessage.TextBody = strMessage
' ''' remote SMTP server configuration section Begin '''
' ''' configure remote SMTP server here '''
' objMessage.Configuration.Fields.Update
' ''' remote SMTP server configuration section End '''
objMessage.Send
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
也请阅读。您到底遇到了什么问题?请尝试使用逻辑来搜索错误日志中的“遇到加载数据”字样,如果存在,请将其附加到电子邮件并发送给其他人。如果它不存在,发送一封没有附件的电子邮件。这样做了。谢谢