I am using a VBScript file named BrowserError.vbs which is accepting one argument from the Java class am using. The vbs file is used send an email when there is a test case failure with a screenshot.
Problem:
If I run the vbs file from command prompt it works fine and sends the email with attachment.
But if I run from the Java class it gives the following error:
No Script engine for .vbs TL02_Validate_ChaterInvalidLogin-1-11Apr16_045433
BrowserError.vbs:
Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim MessageAttachment
Dim name
Dim folder
Dim displayMsg
Dim ol, ns, newMail
name = WScript.Arguments.Item(0)
FromAddress = "[email protected]"
ToAddress = "[email protected]"
CcAddress = "[email protected]"
MessageSubject = "Sanity Error Alert !!!"
Set ol = WScript.CreateObject("Outlook.Application")
Set ns = ol.getNamespace("MAPI")
Set newMail = ol.CreateItem(olMailItem)
MessageAttachment = "C:\Users\****\Desktop\********\CnetWorkSpaceBranch\SanityBranch\target\surefire-reports\html\screenshots\" & name & ".png"
Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(MessageAttachment, 1)
strFileText = "Hi, Error notification on Sanity- User has encountered problem : Refer screenshot "
objFileToRead.Close
Set objFileToRead = Nothing
newMail.Subject = MessageSubject & Now
newMail.HTMLBody = strFileText
newMail.To = ToAddress
newMail.CC = CcAddress
newMail.Display
newMail.Attachments.Add(MessageAttachment).Displayname = "Check this out"
newMail.Send
Set ol = Nothing
The Java code which is used to pass the argument is like this:
String tnm="TL02_Validate_ChaterInvalidLogin-1-11Apr16_045433";
Runtime.getRuntime().exec("wscript C:/BrowserError.vbs"+tnm);
My core interest is to just send the email and get the value from the Java class while running and sending the email.
.vbs. The error message says it is trying to execute a script with an extension ofvbsTL02_Validate_ChaterInvalidLogin-1-11Apr16_045433of which there isn't one. - user6017774